forked from cesanta/docker_auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_test.go
More file actions
51 lines (43 loc) · 1.15 KB
/
Copy pathconfig_test.go
File metadata and controls
51 lines (43 loc) · 1.15 KB
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
41
42
43
44
45
46
47
48
49
50
51
package server
import (
"os"
"testing"
)
func TestLoadConfig(t *testing.T) {
conf, err := LoadConfig("../../examples/reference.yml", "AUTH")
if err != nil {
t.Error(err)
return
}
if conf.Server.Net != "tcp" {
t.Errorf("expected tcp, got %s", conf.Server.Net)
}
}
func TestOverwritingConfig(t *testing.T) {
os.Setenv("AUTH__SERVER__LETSENCRYPT__EMAIL", "test@email.com")
conf, err := LoadConfig("../../examples/reference.yml", "AUTH")
if err != nil {
t.Error(err)
return
}
if conf.Server.Net != "tcp" {
t.Errorf("expected tcp, got %s", conf.Server.Net)
}
if conf.Server.LetsEncrypt.Email != "test@email.com" {
t.Errorf("expected test@email.com, got %s", conf.Server.LetsEncrypt.Email)
}
}
func TestOverwritingConfigWithUnderscore(t *testing.T) {
os.Setenv("AUTH__SERVER__LETSENCRYPT__CACHE_DIR", "/cache/dir")
conf, err := LoadConfig("../../examples/reference.yml", "AUTH")
if err != nil {
t.Error(err)
return
}
if conf.Server.Net != "tcp" {
t.Errorf("expected tcp, got %s", conf.Server.Net)
}
if conf.Server.LetsEncrypt.CacheDir != "/cache/dir" {
t.Errorf("expected /cache/dir, got %s", conf.Server.LetsEncrypt.CacheDir)
}
}