MCPcopy Create free account
hub / github.com/BoRuDar/configuration / TestJSONFileProvider_json

Function TestJSONFileProvider_json

jsonProvider_test.go:11–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestJSONFileProvider_json(t *testing.T) {
12 type test struct {
13 Timeout time.Duration `file_json:"timeout"`
14 }
15
16 testObj := test{}
17 expected := test{
18 Timeout: time.Millisecond * 101,
19 }
20
21 fieldType := reflect.TypeOf(&testObj).Elem().Field(0)
22 fieldVal := reflect.ValueOf(&testObj).Elem().Field(0)
23
24 p := NewJSONFileProvider("./testdata/input.json")
25 if err := p.Init(&testObj); err != nil {
26 t.Fatalf("unexpected error: %v", err)
27 }
28
29 if err := p.Provide(fieldType, fieldVal); err != nil {
30 t.Fatalf("unexpected error: %v", err)
31 }
32
33 assert(t, expected, testObj)
34}
35
36// nolint:errchkjson,musttag
37func TestFindValStrByPath(t *testing.T) {

Callers

nothing calls this directly

Calls 4

NewJSONFileProviderFunction · 0.85
assertFunction · 0.85
InitMethod · 0.65
ProvideMethod · 0.65

Tested by

no test coverage detected