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

Function TestIntegrationAnalyzeSQL

pkg/advisor/optimizer_test.go:1059–1089  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Integration test with AnalyzeSQL ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

1057// ---------------------------------------------------------------------------
1058
1059func TestIntegrationAnalyzeSQL(t *testing.T) {
1060 opt := New()
1061
1062 t.Run("SELECT * produces OPT-001", func(t *testing.T) {
1063 result := mustAnalyze(t, opt, "SELECT * FROM users")
1064 if !hasSuggestion(result, "OPT-001") {
1065 t.Error("expected OPT-001 for SELECT *")
1066 }
1067 })
1068
1069 t.Run("UPDATE without WHERE produces OPT-002", func(t *testing.T) {
1070 result := mustAnalyze(t, opt, "UPDATE users SET name = 'test'")
1071 if !hasSuggestion(result, "OPT-002") {
1072 t.Error("expected OPT-002 for UPDATE without WHERE")
1073 }
1074 })
1075
1076 t.Run("DELETE without WHERE produces OPT-002", func(t *testing.T) {
1077 result := mustAnalyze(t, opt, "DELETE FROM users")
1078 if !hasSuggestion(result, "OPT-002") {
1079 t.Error("expected OPT-002 for DELETE without WHERE")
1080 }
1081 })
1082
1083 t.Run("DISTINCT produces OPT-004", func(t *testing.T) {
1084 result := mustAnalyze(t, opt, "SELECT DISTINCT name FROM users")
1085 if !hasSuggestion(result, "OPT-004") {
1086 t.Error("expected OPT-004 for SELECT DISTINCT")
1087 }
1088 })
1089}
1090
1091func contains(s, substr string) bool {
1092 return len(s) >= len(substr) && containsSubstring(s, substr)

Callers

nothing calls this directly

Calls 5

mustAnalyzeFunction · 0.85
hasSuggestionFunction · 0.85
RunMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected