[gnote] Convert NoteManager test into unit test



commit f5faf6cf486d113c5baa4de4d105696bba725410
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 28 17:07:48 2017 +0200

    Convert NoteManager test into unit test

 src/Makefile.am                     |   15 ++++------
 src/test/notemanagertest.cpp        |   46 ----------------------------------
 src/test/unit/notemanagerutests.cpp |   47 +++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 55 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e87bf3a..64a020e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,8 +23,8 @@ GNOTE_LIBS = libgnote.la $(LIBGNOTE_LIBS)
 
 lib_LTLIBRARIES = libgnote.la
 bin_PROGRAMS = gnote
-check_PROGRAMS = notemanagertest gnotesyncclienttest
-TESTS = notemanagertest gnotesyncclienttest
+check_PROGRAMS = gnotesyncclienttest
+TESTS = gnotesyncclienttest
 
 if HAVE_UNITTESTCPP
 check_PROGRAMS += gnoteunittests
@@ -32,10 +32,14 @@ TESTS += gnoteunittests
 
 gnoteunittests_SOURCES = \
        test/runner.cpp \
+       test/testnote.cpp test/testnote.hpp \
+       test/testnotemanager.cpp test/testnotemanager.hpp \
+       test/testtagmanager.cpp test/testtagmanager.hpp \
        test/unit/datetimeutests.cpp \
        test/unit/filesutests.cpp \
        test/unit/fileinfoutests.cpp \
        test/unit/noteutests.cpp \
+       test/unit/notemanagerutests.cpp \
        test/unit/stringutests.cpp \
        test/unit/trieutests.cpp \
        test/unit/uriutests.cpp \
@@ -45,13 +49,6 @@ gnoteunittests_LDADD = libgnote.la @UNITTESTCPP_LIBS@
 endif
 
 
-notemanagertest_SOURCES = test/notemanagertest.cpp \
-       test/testnote.cpp test/testnote.hpp \
-       test/testnotemanager.cpp test/testnotemanager.hpp \
-       test/testtagmanager.cpp test/testtagmanager.hpp \
-       $(NULL)
-notemanagertest_LDADD = $(GNOTE_LIBS)
-
 gnotesyncclienttest_SOURCES = test/gnotesyncclienttest.cpp \
        test/testnote.cpp test/testnote.hpp \
        test/testnotemanager.cpp test/testnotemanager.hpp \
diff --git a/src/test/unit/notemanagerutests.cpp b/src/test/unit/notemanagerutests.cpp
new file mode 100644
index 0000000..41fc40f
--- /dev/null
+++ b/src/test/unit/notemanagerutests.cpp
@@ -0,0 +1,47 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2017 Aurimas Cernius
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <UnitTest++/UnitTest++.h>
+
+#include "test/testnotemanager.hpp"
+#include "test/testtagmanager.hpp"
+
+
+SUITE(NoteManager)
+{
+  TEST(create_and_find)
+  {
+    char notes_dir_tmpl[] = "/tmp/gnotetestnotesXXXXXX";
+    char *notes_dir = g_mkdtemp(notes_dir_tmpl);
+    CHECK(notes_dir != NULL);
+
+    new test::TagManager;
+    test::NoteManager manager(notes_dir);
+    manager.create();
+    manager.create();
+    gnote::NoteBase::Ptr test_note = manager.create("test note");
+    CHECK(test_note != NULL);
+    // 3 notes + template note
+    CHECK_EQUAL(4, manager.get_notes().size());
+    CHECK(manager.find("test note") == test_note);
+    CHECK(manager.find_by_uri(test_note->uri()) == test_note);
+  }
+}
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]