-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
40 lines (35 loc) · 971 Bytes
/
Copy pathconfig_test.go
File metadata and controls
40 lines (35 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import "testing"
func TestLoadConfigDefaultsToDemoCredentials(t *testing.T) {
t.Setenv("APP_ENV", "")
t.Setenv("API_KEY", "")
t.Setenv("SEED_ON_START", "")
cfg, err := LoadConfig()
if err != nil {
t.Fatalf("LoadConfig returned error: %v", err)
}
if cfg.Environment != "demo" {
t.Fatalf("expected demo environment, got %q", cfg.Environment)
}
if cfg.APIKey != "demo-key" {
t.Fatalf("expected demo-key, got %q", cfg.APIKey)
}
if !cfg.SeedOnStart {
t.Fatal("expected demo seed-on-start default")
}
}
func TestLoadConfigDisablesDemoDefaultsInProduction(t *testing.T) {
t.Setenv("APP_ENV", "production")
t.Setenv("API_KEY", "")
t.Setenv("SEED_ON_START", "")
cfg, err := LoadConfig()
if err != nil {
t.Fatalf("LoadConfig returned error: %v", err)
}
if cfg.APIKey != "" {
t.Fatalf("expected no production default API key, got %q", cfg.APIKey)
}
if cfg.SeedOnStart {
t.Fatal("expected production seed-on-start disabled")
}
}