[rygel] tests: Move database test into own file



commit 997d8ea4ab0401a63fe3037156626eb41ad9346a
Author: Jens Georg <mail jensge org>
Date:   Sat Feb 27 11:36:47 2016 +0100

    tests: Move database test into own file
    
    Signed-off-by: Jens Georg <mail jensge org>

 tests/Makefile.am              |   15 ++++++++++-
 tests/rygel-database-test.vala |   54 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 47db215..2a92527 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,7 +15,8 @@ AUTOMAKE_OPTIONS = subdir-objects
 check_PROGRAMS = rygel-regression \
                                 rygel-user-config-test \
                                 rygel-searchable-container-test \
-                                rygel-object-creator-test
+                                rygel-object-creator-test \
+                                rygel-database-test
 
 TESTS = $(check_PROGRAMS)
 
@@ -165,6 +166,18 @@ rygel_regression_CFLAGS = \
 rygel_regression_LDADD = \
        $(test_server_libs)
 
+rygel_database_test_SOURCES = \
+       rygel-database-test.vala
+rygel_database_test_VALAFLAGS = \
+       $(test_valaflags) \
+       $(RYGEL_COMMON_LIBRYGEL_DB_VALAFLAGS)
+rygel_database_test_CFLAGS = \
+       $(test_cflags) \
+       $(RYGEL_COMMON_LIBRYGEL_DB_CFLAGS)
+rygel_database_test_LDADD = \
+       $(test_libs) \
+       $(RYGEL_COMMON_LIBRYGEL_DB_LIBS)
+
 #rygel_media_engine_test_SOURCES = \
 #      rygel-media-engine-test.vala
 #rygel_media_engine_test_VALAFLAGS = \
diff --git a/tests/rygel-database-test.vala b/tests/rygel-database-test.vala
new file mode 100644
index 0000000..058f9f6
--- /dev/null
+++ b/tests/rygel-database-test.vala
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Rygel 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/**
+ * Test that database errors are reported correctly. This is a side-bug
+ * discovered during fixing this bug.
+ */
+public void test_bgo683926_1 () {
+    Rygel.Database.Database db = null;
+
+    try {
+        db = new Rygel.Database.Database (":memory:");
+        db.exec ("create table object (id text not null, title text not null);");
+        db.exec ("insert into object (id, title) VALUES ('a', 'b');");
+    } catch (Error e) {
+        error ("=> Database preparation failed: %s", e.message);
+    }
+
+    try {
+        Value[] val = { "c" };
+        db.exec ("replace into object (title) VALUES (?);", val);
+        assert_not_reached ();
+    } catch (Error e) {
+        // Receiving an error here is expected
+    }
+}
+
+int main (string[] args) {
+    Test.init (ref args);
+
+    Test.add_func ("/librygel-db/regression/bgo689326_1",
+                   test_bgo683926_1);
+
+    return Test.run ();
+}


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