RequireValidSQL requires that the given SQL is syntactically valid. If the SQL is invalid, the test stops immediately. Example: testing.RequireValidSQL(t, "SELECT * FROM users") // Test continues only if SQL is valid
(t TestingT, sql string)
| 80 | // testing.RequireValidSQL(t, "SELECT * FROM users") |
| 81 | // // Test continues only if SQL is valid |
| 82 | func RequireValidSQL(t TestingT, sql string) { |
| 83 | t.Helper() |
| 84 | |
| 85 | err := gosqlx.Validate(sql) |
| 86 | if err != nil { |
| 87 | t.Fatalf("Required valid SQL, but got error:\n SQL: %s\n Error: %v", |
| 88 | truncateSQL(sql), err) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // RequireInvalidSQL requires that the given SQL is syntactically invalid. |
| 93 | // If the SQL is valid, the test stops immediately. |