test: cover initial recommend fallback inputs

- add coverage for leading-dot recommendation inputs
- verify normal recommendation inputs do not fallback to initial suggestions
This commit is contained in:
douxu 2026-07-08 17:19:07 +08:00
parent d8668afa46
commit 180b0f7843
1 changed files with 25 additions and 0 deletions

View File

@ -99,3 +99,28 @@ func TestFallbackSpecificSetKey(t *testing.T) {
})
}
}
func TestShouldFallbackToInitialRecommend(t *testing.T) {
tests := []struct {
input string
want bool
}{
{input: "", want: false},
{input: ".", want: true},
{input: ".x", want: true},
{input: "..x", want: true},
{input: "...x", want: true},
{input: "grid000", want: false},
{input: "grid000.", want: false},
{input: "grid000.zone000", want: false},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
got := shouldFallbackToInitialRecommend(tt.input)
if got != tt.want {
t.Fatalf("expected %t, got %t", tt.want, got)
}
})
}
}