MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / AssertInvalidSQL

Function AssertInvalidSQL

pkg/gosqlx/testing/testing.go:63–73  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

61//
62// testing.AssertInvalidSQL(t, "SELECT FROM WHERE")
63func 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.

Callers 2

Calls 4

ValidateFunction · 0.92
truncateSQLFunction · 0.85
HelperMethod · 0.65
ErrorfMethod · 0.65

Tested by 2