mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
DeepEqual method seems cleaner than adding Defaulting before every
reflect.DeepEqual call
This commit is contained in:
@@ -6,7 +6,6 @@ package target_test
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -334,12 +333,10 @@ vars:
|
||||
t.Fatalf("unexpected size %d", len(vars))
|
||||
}
|
||||
for i := range vars[:2] {
|
||||
// We have to enforce the Defaulting call in someVars[i]
|
||||
// to protect from a potential call of vars[i].ObjRef.GVK()
|
||||
// By using Var.DeepEqual, we are protecting the code
|
||||
// from a potential invocation of vars[i].ObjRef.GVK()
|
||||
// during AccumulateTarget
|
||||
vars[i].Defaulting()
|
||||
someVars[i].Defaulting()
|
||||
if !reflect.DeepEqual(vars[i], someVars[i]) {
|
||||
if !vars[i].DeepEqual(someVars[i]) {
|
||||
t.Fatalf("unexpected var[%d]:\n %v\n %v", i, vars[i], someVars[i])
|
||||
}
|
||||
}
|
||||
@@ -392,9 +389,10 @@ resources:
|
||||
t.Fatalf("expected 4 vars, got %d", len(vars))
|
||||
}
|
||||
for i := range vars {
|
||||
vars[i].Defaulting()
|
||||
someVars[i].Defaulting()
|
||||
if !reflect.DeepEqual(vars[i], someVars[i]) {
|
||||
// By using Var.DeepEqual, we are protecting the code
|
||||
// from a potential invocation of vars[i].ObjRef.GVK()
|
||||
// during AccumulateTarget
|
||||
if !vars[i].DeepEqual(someVars[i]) {
|
||||
t.Fatalf("unexpected var[%d]:\n %v\n %v", i, vars[i], someVars[i])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user