Cache repeated query translation and expansion
build-push / docker (push) Successful in 5m20s

This commit is contained in:
AI Assistant
2026-03-16 16:15:16 +09:00
parent 60fdd7842c
commit 93b9f571ab
3 changed files with 117 additions and 3 deletions
+26
View File
@@ -88,3 +88,29 @@ func TestGeminiVisualCacheRoundTrip(t *testing.T) {
t.Fatalf("unexpected cached visual data: %q %q", data, mimeType)
}
}
func TestGeminiTranslationCacheRoundTrip(t *testing.T) {
service := NewGeminiService("")
service.setCachedTranslation("비 오는 도시", "rainy city", time.Minute)
value, ok := service.getCachedTranslation("비 오는 도시")
if !ok {
t.Fatal("expected translation cache hit")
}
if value != "rainy city" {
t.Fatalf("unexpected translation cache value: %q", value)
}
}
func TestGeminiExpansionCacheRoundTrip(t *testing.T) {
service := NewGeminiService("")
service.setCachedExpansion("city rain", []string{"city rain", "city rain stock footage"}, time.Minute)
value, ok := service.getCachedExpansion("city rain")
if !ok {
t.Fatal("expected expansion cache hit")
}
if len(value) != 2 || value[1] != "city rain stock footage" {
t.Fatalf("unexpected expansion cache value: %#v", value)
}
}