--------------------------------------------------------------------------- Integration test with AnalyzeSQL ---------------------------------------------------------------------------
(t *testing.T)
| 1057 | // --------------------------------------------------------------------------- |
| 1058 | |
| 1059 | func 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 | |
| 1091 | func contains(s, substr string) bool { |
| 1092 | return len(s) >= len(substr) && containsSubstring(s, substr) |
nothing calls this directly
no test coverage detected