chore: publish IntegraCI build modules 732ec6c83925
This commit is contained in:
1 parent
7a84930dea
commit
5f8a24d014
133 files changed
+18990
-2
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package verdict
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLiquibaseJudgeable(t *testing.T) {
|
||||
refused := []string{
|
||||
"--liquibase formatted sql\n--changeset a:1\n--precondition-sql-check expectedResult:0 WITH d AS (DELETE FROM users RETURNING 1) SELECT count(*) FROM d\nCREATE TABLE t (id int);",
|
||||
"--preconditions onFail:MARK_RAN\nCREATE TABLE t (id int);",
|
||||
"--precondition-table-exists table:t",
|
||||
"--include file:other.sql",
|
||||
"--includeAll path:more/",
|
||||
"--property name:x value:y",
|
||||
"--validCheckSum: ANY",
|
||||
"--ignoreLines:start\nDROP TABLE t;\n--ignoreLines:end",
|
||||
" -- PRECONDITION-SQL-CHECK expectedResult:0 SELECT 1",
|
||||
// A lone \r ends a line for Liquibase.
|
||||
"SELECT 1;\r--precondition-sql-check expectedResult:0 SELECT 1",
|
||||
}
|
||||
for _, sql := range refused {
|
||||
if LiquibaseJudgeable("V1.sql", sql) == nil {
|
||||
t.Errorf("accepted %q", sql)
|
||||
}
|
||||
}
|
||||
// What a tenant's own formatted-SQL changelog legitimately holds.
|
||||
allowed := []string{
|
||||
"--liquibase formatted sql\n--changeset alice:1\nCREATE TABLE t (id int);\n--rollback DROP TABLE t;",
|
||||
"--changeset alice:2 splitStatements:false\nCREATE FUNCTION f() RETURNS int AS $$ SELECT 1 $$ LANGUAGE sql;",
|
||||
"--comment: adds the orders table\nCREATE TABLE orders (id int);",
|
||||
"-- a plain comment about preconditions in prose\nCREATE TABLE t (id int);",
|
||||
"CREATE TABLE includes (id int); -- not a directive",
|
||||
"",
|
||||
}
|
||||
for _, sql := range allowed {
|
||||
if err := LiquibaseJudgeable("V1.sql", sql); err != nil {
|
||||
t.Errorf("refused %q: %v", sql, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user