From 08dc70e547fdf077f94c95b4d74b79a74c0a4f3c Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sat, 25 Jan 2025 19:05:53 -0500 Subject: [PATCH] tests: move test to proper lint (#408) was put in the wrong file in https://github.com/sbdchd/squawk/commit/c3979a9e49c7b6caf4a6db89e887c171472bde68 --- linter/src/rules/adding_field_with_default.rs | 1 - linter/src/rules/ban_char_field.rs | 13 ------------- linter/src/rules/constraint_missing_not_valid.rs | 14 ++++++++++++++ ...id__test_rules__regression_with_indexing_2.snap | 5 +++++ 4 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap diff --git a/linter/src/rules/adding_field_with_default.rs b/linter/src/rules/adding_field_with_default.rs index 468c1fd6..19cfec31 100644 --- a/linter/src/rules/adding_field_with_default.rs +++ b/linter/src/rules/adding_field_with_default.rs @@ -45,7 +45,6 @@ pub fn adding_field_with_default( .filter(|x| !x.is_empty()) .collect(); - // println!("{:#?}", non_volatile_funcs); for raw_stmt in tree { match &raw_stmt.stmt { Stmt::AlterTableStmt(stmt) => { diff --git a/linter/src/rules/ban_char_field.rs b/linter/src/rules/ban_char_field.rs index 6f7e9457..a6e73edb 100644 --- a/linter/src/rules/ban_char_field.rs +++ b/linter/src/rules/ban_char_field.rs @@ -77,17 +77,4 @@ COMMIT; "#; assert_debug_snapshot!(lint_sql(sql)); } - #[test] - fn regression_with_indexing_2() { - let sql = r#" -BEGIN; -ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; -ALTER TABLE "core_recipe" ADD CONSTRAINT foo_not_null - CHECK ("foo" IS NOT NULL) NOT VALID; -COMMIT; -BEGIN; - -"#; - assert_debug_snapshot!(lint_sql(sql)); - } } diff --git a/linter/src/rules/constraint_missing_not_valid.rs b/linter/src/rules/constraint_missing_not_valid.rs index de280558..c146e4ec 100644 --- a/linter/src/rules/constraint_missing_not_valid.rs +++ b/linter/src/rules/constraint_missing_not_valid.rs @@ -265,4 +265,18 @@ ALTER TABLE accounts VALIDATE CONSTRAINT positive_balance; assert_debug_snapshot!(lint_sql(ok_sql)); } + + #[test] + fn regression_with_indexing_2() { + let sql = r#" +BEGIN; +ALTER TABLE "core_recipe" ADD COLUMN "foo" integer DEFAULT 10; +ALTER TABLE "core_recipe" ADD CONSTRAINT foo_not_null + CHECK ("foo" IS NOT NULL) NOT VALID; +COMMIT; +BEGIN; + +"#; + assert_debug_snapshot!(lint_sql(sql)); + } } diff --git a/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap b/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap new file mode 100644 index 00000000..dcab9ba5 --- /dev/null +++ b/linter/src/rules/snapshots/squawk_linter__rules__constraint_missing_not_valid__test_rules__regression_with_indexing_2.snap @@ -0,0 +1,5 @@ +--- +source: linter/src/rules/constraint_missing_not_valid.rs +expression: lint_sql(sql) +--- +[]