mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
RNode copier
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -206,6 +207,33 @@ func TestIsMissingOrNull(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCopy(t *testing.T) {
|
||||
rn := RNode{
|
||||
fieldPath: []string{"fp1", "fp2"},
|
||||
value: &Node{
|
||||
Kind: 200,
|
||||
},
|
||||
Match: []string{"m1", "m2"},
|
||||
}
|
||||
rnC := rn.Copy()
|
||||
if !reflect.DeepEqual(&rn, rnC) {
|
||||
t.Fatalf("copy %v is not deep equal to %v", rnC, rn)
|
||||
}
|
||||
tmp := rn.value.Kind
|
||||
rn.value.Kind = 666
|
||||
if reflect.DeepEqual(rn, rnC) {
|
||||
t.Fatalf("changing component should break equality")
|
||||
}
|
||||
rn.value.Kind = tmp
|
||||
if !reflect.DeepEqual(&rn, rnC) {
|
||||
t.Fatalf("should be back to normal")
|
||||
}
|
||||
rn.fieldPath[0] = "Different"
|
||||
if reflect.DeepEqual(rn, rnC) {
|
||||
t.Fatalf("changing fieldpath should break equality")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFieldRNodes(t *testing.T) {
|
||||
testCases := []struct {
|
||||
testName string
|
||||
|
||||
Reference in New Issue
Block a user