-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_test.go
62 lines (41 loc) · 1.05 KB
/
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
54
55
56
57
58
59
60
61
62
package cypress
import (
"bytes"
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektra/neko"
)
func TestConfig(t *testing.T) {
n := neko.Start(t)
paths := GlobalConfigPaths
n.Cleanup(func() {
GlobalConfigPaths = paths
})
n.It("reads the config via toml", func() {
var buf bytes.Buffer
var tc struct{ AllowUnsigned bool }
buf.WriteString("[s3]\nallow_unsigned = true\n")
cfg, err := ParseConfig(&buf)
require.NoError(t, err)
err = cfg.Load("s3", &tc)
require.NoError(t, err)
assert.True(t, tc.AllowUnsigned)
})
n.It("loads config from config paths", func() {
tmpfile, err := ioutil.TempFile("", "config")
require.NoError(t, err)
defer os.Remove(tmpfile.Name())
tmpfile.Write([]byte("[s3]\nallow_unsigned = true\n"))
tmpfile.Close()
GlobalConfigPaths = []string{tmpfile.Name()}
cfg := loadGlobalConfig()
var tc struct{ AllowUnsigned bool }
err = cfg.Load("s3", &tc)
require.NoError(t, err)
assert.True(t, tc.AllowUnsigned)
})
n.Meow()
}