summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index f825f58..1a53486 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -101,6 +101,33 @@ narration:
}
}
+func TestLoadFallsBackToGoogleAPIKeyEnv(t *testing.T) {
+ t.Setenv("GOOGLE_API_KEY", "fallback-key")
+
+ cfg, err := Load("")
+ if err != nil {
+ t.Fatalf("Load() error = %v", err)
+ }
+
+ if got, want := cfg.GoogleAPIKey(), "fallback-key"; got != want {
+ t.Fatalf("GoogleAPIKey() = %q, want %q", got, want)
+ }
+}
+
+func TestLoadPrefersComicForgeGoogleAPIKeyEnv(t *testing.T) {
+ t.Setenv("GOOGLE_API_KEY", "fallback-key")
+ t.Setenv("COMICFORGE_API_GOOGLE_API_KEY", "comicforge-key")
+
+ cfg, err := Load("")
+ if err != nil {
+ t.Fatalf("Load() error = %v", err)
+ }
+
+ if got, want := cfg.GoogleAPIKey(), "comicforge-key"; got != want {
+ t.Fatalf("GoogleAPIKey() = %q, want %q", got, want)
+ }
+}
+
func TestRenderPrompt(t *testing.T) {
tmpDir := t.TempDir()
cfg := DefaultConfig()