summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-21 23:17:04 +0300
committerPaul Buetow <paul@buetow.org>2026-04-21 23:17:04 +0300
commitd7c7f24385ca1f3a6a86eae5a5255384b4e79632 (patch)
treea545ad31d9b355fab14d2bc0b06aa273c7ab5017 /internal
parentc6950b25e135d176ff26370a43ab54334704e12f (diff)
q7: cover PerPage defaulting in best-match downloads
Diffstat (limited to 'internal')
-rw-r--r--internal/image/download_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/image/download_test.go b/internal/image/download_test.go
index 2033032..cefe757 100644
--- a/internal/image/download_test.go
+++ b/internal/image/download_test.go
@@ -143,6 +143,36 @@ func TestDownloadBestMatchWithOptions(t *testing.T) {
}
}
+func TestDownloadBestMatchWithOptions_DefaultsPerPageWhenUnset(t *testing.T) {
+ t.Parallel()
+
+ provider := &mockDownloaderProvider{
+ results: []SearchResult{
+ {
+ ID: "1",
+ URL: "https://example.com/image1.jpg",
+ Source: Gemini,
+ },
+ },
+ payload: "image-bytes",
+ }
+ d := NewDownloader(provider, &DownloadOptions{
+ OutputDir: t.TempDir(),
+ CreateDir: true,
+ OverwriteExisting: true,
+ FileNamePattern: "{word}_{source}",
+ MaxSizeBytes: 10 * 1024 * 1024,
+ })
+
+ _, _, err := d.DownloadBestMatchWithOptions(context.Background(), &SearchOptions{Query: "ябълка"})
+ if err != nil {
+ t.Fatalf("DownloadBestMatchWithOptions() error = %v", err)
+ }
+ if got, want := provider.searchPerPages, []int{5}; len(got) != len(want) || got[0] != want[0] {
+ t.Fatalf("provider search PerPage = %v, want %v", got, want)
+ }
+}
+
func TestDownloadBestMatchWithOptions_SanitizesUnsafeProviderFields(t *testing.T) {
t.Parallel()