Skip to content

Commit

Permalink
Fix spatialite migration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreilles committed Oct 3, 2024
1 parent 7c834a7 commit 41b829c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl SqlRenderer for SqliteFlavour {
if create_geometries.is_empty() {
create_table.to_string()
} else {
create_table.to_string() + "\n;" + &create_geometries
create_table.to_string() + ";\n" + &create_geometries
}
}

Expand Down
36 changes: 26 additions & 10 deletions schema-engine/sql-migration-tests/tests/migrations/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,19 @@ fn from_multi_file_schema_datasource_to_url(mut api: TestApi) {

api.diff(input).unwrap();

let expected_printed_messages = expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"cows\";\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]];
let expected_printed_messages = if api.tags().contains(test_setup::Tags::Spatialite) {
expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nSELECT DropTable(NULL, 'cows');\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]]
} else {
expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"cows\";\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]]
};
expected_printed_messages.assert_debug_eq(&host.printed_messages.lock().unwrap());
}

Expand Down Expand Up @@ -888,11 +896,19 @@ fn from_multi_file_schema_datamodel_to_url(mut api: TestApi) {

api.diff(input).unwrap();

let expected_printed_messages = expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"cows\";\nPRAGMA foreign_keys=on;\n\n-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"dogs\";\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]];
let expected_printed_messages = if api.tags().contains(test_setup::Tags::Spatialite) {
expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nSELECT DropTable(NULL, 'cows');\nPRAGMA foreign_keys=on;\n\n-- DropTable\nPRAGMA foreign_keys=off;\nSELECT DropTable(NULL, 'dogs');\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]]
} else {
expect![[r#"
[
"-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"cows\";\nPRAGMA foreign_keys=on;\n\n-- DropTable\nPRAGMA foreign_keys=off;\nDROP TABLE \"dogs\";\nPRAGMA foreign_keys=on;\n\n-- CreateTable\nCREATE TABLE \"cats\" (\n \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n \"meows\" BOOLEAN DEFAULT true\n);\n",
]
"#]]
};
expected_printed_messages.assert_debug_eq(&host.printed_messages.lock().unwrap());
}

Expand Down

0 comments on commit 41b829c

Please sign in to comment.