Commit 4179189e authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi/tests: Add more tests for MSIMODIFY_INSERT.

parent 53598374
......@@ -8867,6 +8867,170 @@ todo_wine
DeleteFileA(msifile);
}
static void test_viewmodify_insert(void)
{
MSIHANDLE view, rec, db = create_db();
UINT r;
r = run_query(db, 0, "CREATE TABLE `T` (`A` SHORT, `B` SHORT PRIMARY KEY `A`)");
ok(!r, "got %u\n", r);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `T`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
rec = MsiCreateRecord(2);
MsiRecordSetInteger(rec, 1, 1);
MsiRecordSetInteger(rec, 2, 2);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(!r, "got %u\n", r);
MsiCloseHandle(rec);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `T`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 2, "1", "2");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "got %u\n", r);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `T`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
rec = MsiCreateRecord(2);
MsiRecordSetInteger(rec, 1, 1);
MsiRecordSetInteger(rec, 2, 2);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(r == ERROR_FUNCTION_FAILED, "got %u\n", r);
MsiRecordSetInteger(rec, 2, 3);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(r == ERROR_FUNCTION_FAILED, "got %u\n", r);
MsiRecordSetInteger(rec, 1, 3);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(!r, "got %u\n", r);
MsiCloseHandle(rec);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `T`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 2, "1", "2");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 2, "3", "3");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "got %u\n", r);
MsiCloseHandle(view);
r = run_query(db, 0, "CREATE TABLE `U` (`A` SHORT, `B` SHORT, `C` SHORT, `D` SHORT PRIMARY KEY `A`, `B`)");
ok(!r, "got %u\n", r);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `U`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
rec = MsiCreateRecord(4);
MsiRecordSetInteger(rec, 1, 1);
MsiRecordSetInteger(rec, 2, 2);
MsiRecordSetInteger(rec, 3, 3);
MsiRecordSetInteger(rec, 4, 4);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(!r, "got %u\n", r);
MsiRecordSetInteger(rec, 2, 4);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(!r, "got %u\n", r);
MsiCloseHandle(rec);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `U`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 4, "1", "2", "3", "4");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 4, "1", "4", "3", "4");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "got %u\n", r);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT `A`,`C` FROM `U`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
rec = MsiCreateRecord(2);
MsiRecordSetInteger(rec, 1, 1);
MsiRecordSetInteger(rec, 2, 2);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(!r, "got %u\n", r);
r = MsiViewModify(view, MSIMODIFY_INSERT, rec);
ok(r == ERROR_FUNCTION_FAILED, "got %u\n", r);
MsiCloseHandle(rec);
MsiCloseHandle(view);
r = MsiDatabaseOpenViewA(db, "SELECT * FROM `U` ORDER BY `B`", &view);
ok(!r, "got %u\n", r);
r = MsiViewExecute(view, 0);
ok(!r, "got %u\n", r);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 4, "1", "", "2", "");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 4, "1", "2", "3", "4");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(!r, "got %u\n", r);
check_record(rec, 4, "1", "4", "3", "4");
MsiCloseHandle(rec);
r = MsiViewFetch(view, &rec);
ok(r == ERROR_NO_MORE_ITEMS, "got %u\n", r);
MsiCloseHandle(view);
MsiCloseHandle(db);
DeleteFileA(msifile);
}
START_TEST(db)
{
test_msidatabase();
......@@ -8924,4 +9088,5 @@ START_TEST(db)
test_select_column_names();
test_primary_keys();
test_viewmodify_merge();
test_viewmodify_insert();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment