TestLooksLikeSQL tests the SQL heuristic detection
(t *testing.T)
| 119 | |
| 120 | // TestLooksLikeSQL tests the SQL heuristic detection |
| 121 | func 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 |
| 152 | func TestExpandFileArgs(t *testing.T) { |
nothing calls this directly
no test coverage detected