Last active
March 6, 2019 16:15
-
-
Save aslakknutsen/e7285a70916bbd3e5164a57dbbc3a688 to your computer and use it in GitHub Desktop.
istio API duplication on DeepCopy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"testing" | |
"k8s.io/apimachinery/pkg/runtime" | |
"k8s.io/apimachinery/pkg/runtime/serializer" | |
v1alpha3 "istio.io/api/networking/v1alpha3" | |
istionetwork "istio.io/api/pkg/kube/apis/networking/v1alpha3" | |
) | |
func TestDeepCopyProto(t *testing.T) { | |
vs := &v1alpha3.VirtualService{ | |
Hosts: []string{"details"}, | |
} | |
if len(vs.Hosts) != 1 || vs.Hosts[0] != "details" { | |
t.Errorf("failed to read Hosts: %v", vs.Hosts) | |
} | |
vs = vs.DeepCopy() | |
if len(vs.Hosts) != 1 || vs.Hosts[0] != "details" { | |
t.Errorf("failed to read Hosts: %v", vs.Hosts) | |
} | |
vss := &istionetwork.VirtualService{ | |
Spec: *vs, | |
} | |
if len(vss.Spec.Hosts) != 1 || vss.Spec.Hosts[0] != "details" { | |
t.Errorf("failed to read Hosts: %v", vss.Spec.Hosts) | |
} | |
vss = vss.DeepCopyObject().(*istionetwork.VirtualService) | |
if len(vss.Spec.Hosts) != 1 || vss.Spec.Hosts[0] != "details" { | |
t.Errorf("failed to read Hosts: %v", vss.Spec.Hosts) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment