-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
53 lines (35 loc) · 919 Bytes
/
config_test.go
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
52
53
package apiconfig
import (
"testing"
"github.com/stretchr/testify/assert"
)
type TestConfig struct {
Configuration
Custom string
MyCustomBool bool
Subkey struct {
Opt int
}
}
var TC *TestConfig
func TestLoadConfig(t *testing.T) {
TC = &TestConfig{
Configuration: *NewConfig(""),
}
LoadConfig(TC)
assert.Equal(t, "testtoken", TC.AuthToken(), "The token should be: testtoken")
}
func TestSyncConfig(t *testing.T) {
TC.Token = "TestSync"
TC.Sync()
assert.Equal(t, "TestSync", TC.AuthToken(), "The token should be: TestSync")
TC.Token = "testtoken"
TC.Sync()
assert.Equal(t, "testtoken", TC.AuthToken(), "The token should be: testtoken")
}
func TestCustomOption(t *testing.T) {
assert.Equal(t, "My Option", TC.Custom, "The Custom json key does not match")
}
func TestSubkeyOption(t *testing.T) {
assert.Equal(t, 123, TC.Subkey.Opt, "Config.Subkey.Opt does not match")
}