AssertInvalidSQL asserts that the given SQL is syntactically invalid. If the SQL is valid, the test continues but is marked as failed. Example: testing.AssertInvalidSQL(t, "SELECT FROM WHERE")
(t TestingT, sql string)
| 61 | // |
| 62 | // testing.AssertInvalidSQL(t, "SELECT FROM WHERE") |
| 63 | func AssertInvalidSQL(t TestingT, sql string) bool { |
| 64 | t.Helper() |
| 65 | |
| 66 | err := gosqlx.Validate(sql) |
| 67 | if err == nil { |
| 68 | t.Errorf("Expected invalid SQL, but it parsed successfully:\n SQL: %s", |
| 69 | truncateSQL(sql)) |
| 70 | return false |
| 71 | } |
| 72 | return true |
| 73 | } |
| 74 | |
| 75 | // RequireValidSQL requires that the given SQL is syntactically valid. |
| 76 | // If the SQL is invalid, the test stops immediately. |