Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/tests/db.c | 165 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+)
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 2ff9fe2a5e..0382e5454f 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -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(); }