MCPcopy
hub / github.com/TomWright/dasel / TestMapCopy

Function TestMapCopy

model/value_map_test.go:155–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

153}
154
155func TestMapCopy(t *testing.T) {
156 orig := model.NewValue(orderedmap.NewMap().Set("a", "one").Set("b", "two"))
157 cp, err := orig.MapCopy()
158 if err != nil {
159 t.Fatal(err)
160 }
161 // Modify original
162 if err := orig.SetMapKey("a", model.NewStringValue("modified")); err != nil {
163 t.Fatal(err)
164 }
165 // Copy should be unchanged
166 val, err := cp.GetMapKey("a")
167 if err != nil {
168 t.Fatal(err)
169 }
170 got, err := val.StringValue()
171 if err != nil {
172 t.Fatal(err)
173 }
174 if got != "one" {
175 t.Errorf("expected 'one', got %s", got)
176 }
177}
178
179func TestMapKeyExists(t *testing.T) {
180 m := model.NewValue(orderedmap.NewMap().Set("exists", "val"))

Callers

nothing calls this directly

Calls 8

MapCopyMethod · 0.95
SetMapKeyMethod · 0.95
NewValueFunction · 0.92
NewMapFunction · 0.92
NewStringValueFunction · 0.92
GetMapKeyMethod · 0.80
StringValueMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected