msi: Add a test for MsiDatabaseExport.
This commit is contained in:
parent
e9cc5156db
commit
d2dca89c52
|
@ -812,6 +812,82 @@ static void test_viewgetcolumninfo(void)
|
||||||
MsiCloseHandle( hdb );
|
MsiCloseHandle( hdb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_msiexport(void)
|
||||||
|
{
|
||||||
|
MSIHANDLE hdb = 0, hview = 0;
|
||||||
|
UINT r;
|
||||||
|
char *query;
|
||||||
|
char path[MAX_PATH];
|
||||||
|
const char file[] = "phone.txt";
|
||||||
|
HANDLE handle;
|
||||||
|
char buffer[0x100];
|
||||||
|
DWORD length;
|
||||||
|
const char expected[] =
|
||||||
|
"id\tname\tnumber\r\n"
|
||||||
|
"I2\tS32\tS32\r\n"
|
||||||
|
"phone\tid\r\n"
|
||||||
|
"1\tAbe\t8675309\r\n";
|
||||||
|
|
||||||
|
DeleteFile(msifile);
|
||||||
|
|
||||||
|
/* just MsiOpenDatabase should not create a file */
|
||||||
|
r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
|
||||||
|
|
||||||
|
/* create a table */
|
||||||
|
query = "CREATE TABLE `phone` ( "
|
||||||
|
"`id` INT, `name` CHAR(32), `number` CHAR(32) "
|
||||||
|
"PRIMARY KEY `id`)";
|
||||||
|
r = MsiDatabaseOpenView(hdb, query, &hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
|
||||||
|
r = MsiViewExecute(hview, 0);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
|
||||||
|
r = MsiViewClose(hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
|
||||||
|
r = MsiCloseHandle(hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
|
||||||
|
|
||||||
|
/* insert a value into it */
|
||||||
|
query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
|
||||||
|
"VALUES('1', 'Abe', '8675309')";
|
||||||
|
r = MsiDatabaseOpenView(hdb, query, &hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
|
||||||
|
r = MsiViewExecute(hview, 0);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
|
||||||
|
r = MsiViewClose(hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
|
||||||
|
r = MsiCloseHandle(hview);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
|
||||||
|
|
||||||
|
GetCurrentDirectory(MAX_PATH, path);
|
||||||
|
|
||||||
|
todo_wine {
|
||||||
|
r = MsiDatabaseExport(hdb, "phone", path, file);
|
||||||
|
ok(r == ERROR_SUCCESS, "MsiDatabaseExport failed\n");
|
||||||
|
|
||||||
|
MsiCloseHandle(hdb);
|
||||||
|
|
||||||
|
lstrcat(path, "\\");
|
||||||
|
lstrcat(path, file);
|
||||||
|
|
||||||
|
/* check the data that was written */
|
||||||
|
length = 0;
|
||||||
|
memset(buffer, 0, sizeof buffer);
|
||||||
|
handle = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
ReadFile(handle, buffer, sizeof buffer, &length, NULL);
|
||||||
|
CloseHandle(handle);
|
||||||
|
DeleteFile(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok(0, "failed to open file %s\n", path);
|
||||||
|
|
||||||
|
ok( length == strlen(expected), "length of data wrong\n");
|
||||||
|
ok( !lstrcmp(buffer, expected), "data doesn't match\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(db)
|
START_TEST(db)
|
||||||
{
|
{
|
||||||
test_msidatabase();
|
test_msidatabase();
|
||||||
|
@ -821,4 +897,5 @@ START_TEST(db)
|
||||||
test_viewmodify();
|
test_viewmodify();
|
||||||
test_viewgetcolumninfo();
|
test_viewgetcolumninfo();
|
||||||
test_getcolinfo();
|
test_getcolinfo();
|
||||||
|
test_msiexport();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue