[Pkg-owncloud-commits] [owncloud-client] 31/211: csync tests: conform to read only db.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 61967f6e1bf5ded8ee2e17888765555d7b6b3d1c
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Oct 9 17:45:10 2014 +0200

    csync tests: conform to read only db.
---
 .../tests/csync_tests/check_csync_statedb_query.c  | 87 +++++-----------------
 1 file changed, 19 insertions(+), 68 deletions(-)

diff --git a/csync/tests/csync_tests/check_csync_statedb_query.c b/csync/tests/csync_tests/check_csync_statedb_query.c
index 2021686..66f6e04 100644
--- a/csync/tests/csync_tests/check_csync_statedb_query.c
+++ b/csync/tests/csync_tests/check_csync_statedb_query.c
@@ -55,19 +55,11 @@ static void setup(void **state)
 
 static void setup_db(void **state)
 {
-    CSYNC *csync;
-    char *stmt = NULL;
+    char *errmsg;
     int rc = 0;
-    c_strlist_t *result = NULL;
-
-    setup(state);
-    csync = *state;
+    sqlite3 *db = NULL;
 
-    // rc = csync_statedb_create_tables(csync->statedb.db);
-    assert_int_equal(rc, 0);
-
-    result = csync_statedb_query(csync->statedb.db,
-        "CREATE TABLE IF NOT EXISTS metadata ("
+    const char *sql = "CREATE TABLE IF NOT EXISTS metadata ("
         "phash INTEGER(8),"
         "pathlen INTEGER,"
         "path VARCHAR(4096),"
@@ -79,29 +71,25 @@ static void setup_db(void **state)
         "type INTEGER,"
         "md5 VARCHAR(32),"
         "PRIMARY KEY(phash)"
-        ");"
-        );
+        ");";
 
-    assert_non_null(result);
-    c_strlist_destroy(result);
+        const char *sql2 = "INSERT INTO metadata"
+                           "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5) VALUES"
+                           "(42, 42, 'Its funny stuff', 23, 42, 43, 55, 66, 2, 54);";
 
 
-    stmt = sqlite3_mprintf("INSERT INTO metadata"
-                           "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5) VALUES"
-                           "(%lu, %d, '%q', %d, %d, %d, %d, %lu, %d, %lu);",
-                           42,
-                           42,
-                           "It's a rainy day",
-                           23,
-                           42,
-                           42,
-                           42,
-                           42,
-                           2,
-                           43);
-
-    // rc = csync_statedb_insert(csync->statedb.db, stmt);
-    sqlite3_free(stmt);
+    setup(state);
+    rc = sqlite3_open( TESTDB, &db);
+    assert_int_equal(rc, SQLITE_OK);
+
+    rc = sqlite3_exec( db, sql, NULL, NULL, &errmsg );
+    assert_int_equal(rc, SQLITE_OK);
+
+    rc = sqlite3_exec( db, sql2, NULL, NULL, &errmsg );
+    assert_int_equal(rc, SQLITE_OK);
+
+    sqlite3_close(db);
+
 }
 
 static void teardown(void **state) {
@@ -139,41 +127,6 @@ static void check_csync_statedb_query_statement(void **state)
     }
 }
 
-static void check_csync_statedb_create_error(void **state)
-{
-    CSYNC *csync = *state;
-    c_strlist_t *result;
-
-    result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
-    assert_non_null(result);
-    c_strlist_destroy(result);
-
-    result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
-    assert_null(result);
-
-    c_strlist_destroy(result);
-}
-
-static void check_csync_statedb_insert_statement(void **state)
-{
-    CSYNC *csync = *state;
-    c_strlist_t *result;
-    int rc = 0;
-
-    result = csync_statedb_query(csync->statedb.db, "CREATE TABLE test(phash INTEGER, text VARCHAR(10));");
-    assert_non_null(result);
-    c_strlist_destroy(result);
-
-    // rc = csync_statedb_insert(csync->statedb.db, "INSERT;");
-    assert_int_equal(rc, 0);
-    // rc = csync_statedb_insert(csync->statedb.db, "INSERT");
-    assert_int_equal(rc, 0);
-    // rc = csync_statedb_insert(csync->statedb.db, "");
-    assert_int_equal(rc, 0);
-}
-
-
-
 static void check_csync_statedb_drop_tables(void **state)
 {
     // CSYNC *csync = *state;
@@ -255,8 +208,6 @@ int torture_run_tests(void)
 {
     const UnitTest tests[] = {
         unit_test_setup_teardown(check_csync_statedb_query_statement, setup, teardown),
-        unit_test_setup_teardown(check_csync_statedb_create_error, setup, teardown),
-        unit_test_setup_teardown(check_csync_statedb_insert_statement, setup, teardown),
         unit_test_setup_teardown(check_csync_statedb_drop_tables, setup, teardown),
         unit_test_setup_teardown(check_csync_statedb_insert_metadata, setup, teardown),
         unit_test_setup_teardown(check_csync_statedb_write, setup, teardown),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list