(t *testing.T)
| 9 | "unicode/utf8" |
| 10 | "unsafe" |
| 11 | |
| 12 | "github.com/posthog/duckgres/server/observe" |
| 13 | "github.com/posthog/duckgres/server/usersecrets" |
| 14 | ) |
| 15 | |
| 16 | func TestClassifyQuery(t *testing.T) { |
| 17 | tests := []struct { |
| 18 | cmdType string |
| 19 | want string |
| 20 | }{ |
| 21 | {"SELECT", "Select"}, |
| 22 | {"SHOW", "Select"}, |
| 23 | {"TABLE", "Select"}, |
| 24 | {"VALUES", "Select"}, |
| 25 | {"EXPLAIN", "Select"}, |
| 26 | {"INSERT", "Insert"}, |
| 27 | {"UPDATE", "Update"}, |
| 28 | {"DELETE", "Delete"}, |
| 29 | {"CREATE", "DDL"}, |
| 30 | {"ALTER", "DDL"}, |
| 31 | {"DROP", "DDL"}, |
| 32 | {"TRUNCATE", "DDL"}, |
| 33 | {"COPY", "Copy"}, |
| 34 | {"BEGIN", "Utility"}, |
| 35 | {"COMMIT", "Utility"}, |
| 36 | {"ROLLBACK", "Utility"}, |
| 37 | {"SET", "Utility"}, |
| 38 | {"RESET", "Utility"}, |
| 39 | {"DISCARD", "Utility"}, |
| 40 | {"DEALLOCATE", "Utility"}, |
| 41 | {"LISTEN", "Utility"}, |
| 42 | {"NOTIFY", "Utility"}, |
| 43 | {"UNLISTEN", "Utility"}, |
| 44 | {"UNKNOWN", "Utility"}, |
| 45 | {"", "Utility"}, |
| 46 | } |
| 47 | |
| 48 | for _, tt := range tests { |
| 49 | t.Run(tt.cmdType, func(t *testing.T) { |
| 50 | got := classifyQuery(tt.cmdType) |
| 51 | if got != tt.want { |
| 52 | t.Errorf("classifyQuery(%q) = %q, want %q", tt.cmdType, got, tt.want) |
| 53 | } |
| 54 | }) |
nothing calls this directly
no test coverage detected