MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestReadSingleConfig

Function TestReadSingleConfig

pkg/config/files_test.go:34–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32}
33
34func TestReadSingleConfig(t *testing.T) {
35 t.Parallel()
36 a := assertions.New(t)
37
38 _, filename, _, _ := runtime.Caller(0)
39
40 first := path.Join(filepath.Dir(filename), "first.yml")
41 second := path.Join(filepath.Dir(filename), "second.yml")
42 _ = second
43
44 defaults := &singleFileConfig{}
45
46 mgr := InitializeWithDefaults("empty", "empty", defaults)
47 a.So(mgr, should.NotBeNil)
48
49 err := mgr.Parse("--config", first)
50 a.So(err, should.BeNil)
51
52 err = mgr.ReadInConfig()
53 a.So(err, should.BeNil)
54
55 res := new(singleFileConfig)
56 err = mgr.Unmarshal(res)
57 a.So(err, should.BeNil)
58
59 a.So(res.Foo, should.Resemble, "10")
60 a.So(res.Bar, should.Resemble, map[string]string{
61 "a": "baz",
62 "b": "quu",
63 })
64}
65
66type multiFileConfig struct {
67 ConfigPaths []string `name:"config"`

Callers

nothing calls this directly

Calls 8

InitializeWithDefaultsFunction · 0.85
DirMethod · 0.80
ReadInConfigMethod · 0.80
NewMethod · 0.65
CallerMethod · 0.65
JoinMethod · 0.65
ParseMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected