Skip to content

Commit 0e2ca42

Browse files
committed
add a way to skip some tests on some databases
1 parent 8b700be commit 0e2ca42

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/webserver/database/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ pub fn highlight_sql_error(
5050
}
5151
anyhow::Error::new(db_err).context(msg)
5252
}
53+
54+
impl std::fmt::Display for Database {
55+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56+
write!(f, "{:?}", self.connection.any_kind())
57+
}
58+
}

tests/index.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ async fn test_files() {
133133
if test_file_path.extension().unwrap_or_default() != "sql" {
134134
continue;
135135
}
136+
if test_file_path_string.contains(&format!("no{}", app_data.db.to_string().to_lowercase()))
137+
{
138+
// skipping because the test does not support the database
139+
continue;
140+
}
136141
let req_str = format!("/{}?x=1", test_file_path_string);
137142
let resp = req_path_with_app_data(&req_str, app_data.clone())
138143
.await

tests/sql_test_files/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Files with names starting with `it_works` should all
66
return a page that contains the text "It works !" and does not contain the
77
text "error" (case insensitive) when executed.
88

9+
If a file name contains `nosqlite`, `nomssql`, `nopostgres` or `nomysql`, then
10+
the test will be ignored when running against the corresponding database.
11+
This allows using syntax that is not supported on all databases in some tests.
12+
913
## `error_` files
1014

1115
Files with names starting with `error` should all return a page that contains
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- Doesnt work on mssql because it does not support "create temporary table"
12
create temporary table temp_t(x text);
23
insert into temp_t(x) values ('It works !');
34
select 'dynamic' as component, sqlpage.run_sql('tests/select_temp_t.sql') AS properties;

0 commit comments

Comments
 (0)