MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / TestDiff

Function TestDiff

internal/node/node_test.go:183–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func TestDiff(t *testing.T) {
184
185 original := &yaml.Node{Kind: yaml.MappingNode, Content: make([]*yaml.Node, 0)}
186 override := &yaml.Node{Kind: yaml.MappingNode, Content: make([]*yaml.Node, 0)}
187
188 original.Content = append(original.Content,
189 &yaml.Node{Kind: yaml.ScalarNode, Value: "A"})
190 original.Content = append(original.Content,
191 &yaml.Node{Kind: yaml.ScalarNode, Value: "foo"})
192
193 override.Content = append(override.Content,
194 &yaml.Node{Kind: yaml.ScalarNode, Value: "A"})
195 override.Content = append(override.Content,
196 &yaml.Node{Kind: yaml.ScalarNode, Value: "bar"})
197
198 diff := node.Diff(original, override)
199 if len(diff) != 2 {
200 t.Fatalf("should have one difference, got %d", len(diff))
201 }
202
203 override.Content[1].Value = "foo"
204 diff = node.Diff(original, override)
205 if len(diff) != 0 {
206 t.Fatalf("should have no difference, got %d", len(diff))
207 }
208
209}
210
211func TestMergeNodes(t *testing.T) {
212 original := &yaml.Node{Kind: yaml.MappingNode, Content: make([]*yaml.Node, 0)}

Callers

nothing calls this directly

Calls 1

DiffFunction · 0.92

Tested by

no test coverage detected