diff --git a/model/redis_recommend_test.go b/model/redis_recommend_test.go index c611e68..3c5f4c4 100644 --- a/model/redis_recommend_test.go +++ b/model/redis_recommend_test.go @@ -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) + } + }) + } +}