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

Function TestLooksLikeSQL

cmd/gosqlx/cmd/integration_test.go:121–149  ·  view source on GitHub ↗

TestLooksLikeSQL tests the SQL heuristic detection

(t *testing.T)

Source from the content-addressed store, hash-verified

119
120// TestLooksLikeSQL tests the SQL heuristic detection
121func TestLooksLikeSQL(t *testing.T) {
122 testCases := []struct {
123 name string
124 input string
125 expected bool
126 }{
127 {"SimpleSelect", "SELECT * FROM users", true},
128 {"InsertStatement", "INSERT INTO table VALUES (1, 'test')", true},
129 {"UpdateStatement", "UPDATE users SET name = 'John'", true},
130 {"DeleteStatement", "DELETE FROM users WHERE id = 1", true},
131 {"CreateStatement", "CREATE TABLE users (id INT)", true},
132 {"WithCTE", "WITH cte AS (SELECT 1) SELECT * FROM cte", true},
133 {"LowercaseSelect", "select id from users", true},
134 {"SQLWithSemicolon", "some random text; but has semicolon", false},
135 {"PlainText", "this is just plain text", false},
136 {"Filename", "myfile.sql", false},
137 {"Path", "/path/to/file", false},
138 {"Empty", "", false},
139 }
140
141 for _, tc := range testCases {
142 t.Run(tc.name, func(t *testing.T) {
143 result := looksLikeSQL(tc.input)
144 if result != tc.expected {
145 t.Errorf("looksLikeSQL(%q) = %v, expected %v", tc.input, result, tc.expected)
146 }
147 })
148 }
149}
150
151// TestExpandFileArgs tests the file expansion functionality
152func TestExpandFileArgs(t *testing.T) {

Callers

nothing calls this directly

Calls 3

looksLikeSQLFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected