MCPcopy
hub / github.com/knadh/koanf / TestSet

Function TestSet

tests/koanf_test.go:1099–1122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1097}
1098
1099func TestSet(t *testing.T) {
1100 var (
1101 assert = assert.New(t)
1102 k = koanf.New(delim)
1103 )
1104 assert.Nil(k.Load(file.Provider(mockYAML), yaml.Parser()),
1105 "error loading file")
1106
1107 assert.Nil(k.Set("parent1.name", "new"))
1108 assert.Equal(k.String("parent1.name"), "new")
1109
1110 assert.Nil(k.Set("parent1.child1.name", 123))
1111 assert.Equal(k.Int("parent1.child1.name"), 123)
1112
1113 assert.Nil(k.Set("parent1.child1.grandchild1.ids", []int{5}))
1114 assert.Equal(k.Ints("parent1.child1.grandchild1.ids"), []int{5})
1115
1116 assert.Nil(k.Set("parent1.child1.grandchild1", 123))
1117 assert.Equal(k.Int("parent1.child1.grandchild1"), 123)
1118 assert.Equal(k.Int("parent1.child1.grandchild1.ids"), 0)
1119
1120 assert.Nil(k.Set("parent1.child1.grandchild1", map[string]any{"name": "new"}))
1121 assert.Equal(k.Get("parent1.child1.grandchild1"), map[string]any{"name": "new"})
1122}
1123
1124func TestUnmarshal(t *testing.T) {
1125 assert := assert.New(t)

Callers

nothing calls this directly

Calls 6

LoadMethod · 0.80
SetMethod · 0.80
StringMethod · 0.80
IntMethod · 0.80
IntsMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…