This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestExtractVideoPreviewURLFindsEnvatoPreview(t *testing.T) {
|
||||
@@ -113,3 +114,30 @@ func TestGeminiCandidateLimitNeverExceedsCandidates(t *testing.T) {
|
||||
t.Fatalf("expected Gemini limit to stay within candidate count, got %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLimitCollectorQueriesUsesSmallerBudgetForMissingPass(t *testing.T) {
|
||||
queries := []string{"a", "b", "c", "d"}
|
||||
|
||||
got := limitCollectorQueries("Artgrid", queries, true)
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("expected 2 queries for missing-pass Artgrid collector, got %d", len(got))
|
||||
}
|
||||
|
||||
got = limitCollectorQueries("Google Video", queries, false)
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("expected 2 queries for Google Video collector, got %d", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchServiceFetchCacheRoundTrip(t *testing.T) {
|
||||
service := NewSearchService("http://example.com", "", "")
|
||||
service.setCachedFetchResult("html\nhttps://example.com/item", "<html></html>", time.Minute)
|
||||
|
||||
body, ok := service.getCachedFetchResult("html\nhttps://example.com/item")
|
||||
if !ok {
|
||||
t.Fatal("expected cached fetch result")
|
||||
}
|
||||
if body != "<html></html>" {
|
||||
t.Fatalf("unexpected cached body: %q", body)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user