summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-12-17 12:44:39 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-09 13:56:07 +0100
commit9b1b206a8881205b285db07733487283b6a8a806 (patch)
treea0f2b01fc53672c2aa8fb0f7f2d595385a47db1b /tests
parent377666075f7eb5ee07e0c76ed18ce417f7491150 (diff)
downloadmsitools-9b1b206a8881205b285db07733487283b6a8a806.tar.gz
msitools-9b1b206a8881205b285db07733487283b6a8a806.tar.xz
msitools-9b1b206a8881205b285db07733487283b6a8a806.zip
database: make import() GObject-like
Diffstat (limited to 'tests')
-rw-r--r--tests/testdatabase.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/testdatabase.c b/tests/testdatabase.c
index abc2d30..8386dbf 100644
--- a/tests/testdatabase.c
+++ b/tests/testdatabase.c
@@ -1689,10 +1689,14 @@ static void write_file(const char *filename, const char *data, int data_size)
static unsigned add_table_to_db(LibmsiDatabase *hdb, const char *table_data)
{
- unsigned r;
+ GError *err = NULL;
+ unsigned r = LIBMSI_RESULT_SUCCESS;
write_file("temp_file", table_data, (strlen(table_data) - 1) * sizeof(char));
- r = libmsi_database_import(hdb, CURR_DIR, "temp_file");
+ if (!libmsi_database_import(hdb, CURR_DIR, "temp_file", &err))
+ r = err->code;
+
+ g_clear_error(&err);
unlink("temp_file");
return r;
@@ -2024,8 +2028,8 @@ static void test_binary_import(void)
hdb = libmsi_database_new(msifile, LIBMSI_DB_OPEN_CREATE, NULL);
ok(hdb , "Failed to open database\n");
- r = libmsi_database_import(hdb, CURR_DIR, "bin_import.idt");
- ok(r == LIBMSI_RESULT_SUCCESS , "Failed to import Binary table\n");
+ r = libmsi_database_import(hdb, CURR_DIR, "bin_import.idt", NULL);
+ ok(r , "Failed to import Binary table\n");
/* read file from the Binary table */
sql = "SELECT * FROM `Binary`";
@@ -5253,8 +5257,8 @@ static void test_quotes(void)
write_file("import.idt", import_dat, (sizeof(import_dat) - 1) * sizeof(char));
- r = libmsi_database_import(hdb, CURR_DIR, "import.idt");
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %d\n", r);
+ r = libmsi_database_import(hdb, CURR_DIR, "import.idt", NULL);
+ ok(r, "libmsi_database_import() failed\n");
unlink("import.idt");
@@ -5679,8 +5683,8 @@ static void test_forcecodepage(void)
create_file_data("forcecodepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0);
- r = libmsi_database_import(hdb, CURR_DIR, "forcecodepage.idt");
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %d\n", r);
+ r = libmsi_database_import(hdb, CURR_DIR, "forcecodepage.idt", NULL);
+ ok(r, "libmsi_database_import() failed\n");
fd = open("forcecodepage.idt", O_WRONLY | O_BINARY | O_CREAT, 0644);
ok(fd != -1, "cannot open file\n");
@@ -5695,8 +5699,8 @@ static void test_forcecodepage(void)
create_file_data("forcecodepage.idt", "\r\n\r\n9999\t_ForceCodepage\r\n", 0);
- r = libmsi_database_import(hdb, CURR_DIR, "forcecodepage.idt");
- ok(r == LIBMSI_RESULT_FUNCTION_FAILED, "Expected LIBMSI_RESULT_FUNCTION_FAILED, got %d\n", r);
+ r = libmsi_database_import(hdb, CURR_DIR, "forcecodepage.idt", NULL);
+ ok(!r, "Expected failure\n");
g_object_unref(hdb);
unlink(msifile);
@@ -6477,8 +6481,8 @@ static void test_dbmerge(void)
create_file_data("codepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0);
- r = libmsi_database_import(hdb, CURR_DIR, "codepage.idt");
- ok(r == LIBMSI_RESULT_SUCCESS, "Expected LIBMSI_RESULT_SUCCESS, got %d\n", r);
+ r = libmsi_database_import(hdb, CURR_DIR, "codepage.idt", NULL);
+ ok(r, "libmsi_database_import() failed\n");
sql = "DROP TABLE `One`";
r = run_query(hdb, 0, sql);
@@ -7261,8 +7265,8 @@ static void test_embedded_nulls(void)
ok(hdb, "failed to open database %u\n", r );
write_file( "temp_file", control_table, sizeof(control_table) );
- r = libmsi_database_import( hdb, CURR_DIR, "temp_file" );
- ok( r == LIBMSI_RESULT_SUCCESS, "failed to import table %u\n", r );
+ r = libmsi_database_import( hdb, CURR_DIR, "temp_file", NULL);
+ ok(r, "libmsi_database_import() failed\n");
unlink( "temp_file" );
r = do_query( hdb, "SELECT `Text` FROM `Control` WHERE `Dialog` = 'LicenseAgreementDlg'", &hrec );