Skip to content

Commit b0015ba

Browse files
fix: update tests for multiple suggestions feature
Updated tests to reflect new behavior where parseSuggestions returns 3-5 suggestions instead of just one. Changes: - Updated TestBuildSuggestSystemPrompt to check for "3-5" and "alternative" - Updated TestParseSuggestions to accept at least 1 suggestion (not exactly 1) - Changed multiline test case to reflect new multi-suggestion behavior - Updated test assertions to check "first" suggestion All tests now pass with the new multiple suggestions feature. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 55f0eee commit b0015ba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

internal/ai/prompts_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func TestBuildSuggestSystemPrompt(t *testing.T) {
1717
// Verify it contains key instructions
1818
requiredPhrases := []string{
1919
"shell command",
20-
"ONLY the complete command",
20+
"3-5",
21+
"alternative",
2122
"safe",
2223
"context",
2324
}
@@ -177,10 +178,10 @@ func TestParseSuggestions(t *testing.T) {
177178
wantRisk: core.RiskMedium,
178179
},
179180
{
180-
name: "multiline response",
181-
response: "git status\nThis shows the status",
181+
name: "multiline response (now returns multiple suggestions)",
182+
response: "git status\ngit st",
182183
originalLine: "git st",
183-
wantCommand: "git status",
184+
wantCommand: "git status", // First suggestion
184185
wantRisk: core.RiskLow,
185186
},
186187
{
@@ -203,16 +204,17 @@ func TestParseSuggestions(t *testing.T) {
203204
return
204205
}
205206

206-
if len(suggestions) != 1 {
207-
t.Fatalf("Expected 1 suggestion, got %d", len(suggestions))
207+
if len(suggestions) < 1 {
208+
t.Fatalf("Expected at least 1 suggestion, got %d", len(suggestions))
208209
}
209210

211+
// Check the first suggestion matches expected
210212
suggestion := suggestions[0]
211213
if suggestion.Command != tt.wantCommand {
212-
t.Errorf("Command = %q, want %q", suggestion.Command, tt.wantCommand)
214+
t.Errorf("First command = %q, want %q", suggestion.Command, tt.wantCommand)
213215
}
214216
if suggestion.Risk != tt.wantRisk {
215-
t.Errorf("Risk = %v, want %v", suggestion.Risk, tt.wantRisk)
217+
t.Errorf("First risk = %v, want %v", suggestion.Risk, tt.wantRisk)
216218
}
217219
if suggestion.Source != "llm" {
218220
t.Errorf("Source = %q, want llm", suggestion.Source)

0 commit comments

Comments
 (0)