-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparsing_test.go
More file actions
31 lines (27 loc) · 825 Bytes
/
parsing_test.go
File metadata and controls
31 lines (27 loc) · 825 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
package figtree
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTree_Parse(t *testing.T) {
figs := With(Options{Germinate: true})
assert.Nil(t, figs.Parse())
}
func TestTree_ParseFile(t *testing.T) {
exts := []string{"yaml", "json", "ini"}
for _, ext := range exts {
t.Run(ext, func(t *testing.T) {
p := filepath.Join(".", "test.config."+ext)
figs := With(Options{Germinate: true})
figs = figs.NewString("name", "", "name")
figs = figs.WithValidator("name", AssureStringContains("yahuah"))
figs = figs.NewInt("age", 0, "age")
figs = figs.WithValidator("age", AssureIntInRange(17, 47))
figs = figs.NewString("sex", "", "sex")
figs = figs.WithValidator("sex", AssureStringHasSuffix("male"))
err := figs.ParseFile(p)
assert.NoError(t, err)
})
}
}