https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5da3f84d5a6a7a1713df1…
commit 5da3f84d5a6a7a1713df13390f0d62c38bff9a80
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Mar 13 00:16:41 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:13 2022 +0100
[WINESYNC] msi/tests: Add more tests for MSIMODIFY_INSERT.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 4179189ec6638ec74cf54eea68798218798affc1 by Zebediah Figura
<z.figura12(a)gmail.com>
---
modules/rostests/winetests/msi/db.c | 165 ++++++++++++++++++++++++++++++++++++
1 file changed, 165 insertions(+)
diff --git a/modules/rostests/winetests/msi/db.c b/modules/rostests/winetests/msi/db.c
index 2ff9fe2a5ef..0382e5454f6 100644
--- a/modules/rostests/winetests/msi/db.c
+++ b/modules/rostests/winetests/msi/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();
}