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

Function RequireValidSQL

pkg/gosqlx/testing/testing.go:82–90  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

80// testing.RequireValidSQL(t, "SELECT * FROM users")
81// // Test continues only if SQL is valid
82func 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.

Callers 2

Calls 4

ValidateFunction · 0.92
truncateSQLFunction · 0.85
HelperMethod · 0.65
FatalfMethod · 0.65

Tested by 2