mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Remove defaulting from test that uses kubectl.Scheme
The dependency on printers/internalversion was causing kubectl/scheme to have defaulters registered, which should not be the case. Remove defaults from the test.
This commit is contained in:
parent
defd8713ac
commit
c21774e9de
@ -62,6 +62,7 @@ go_test(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
"//vendor/k8s.io/utils/exec:go_default_library",
|
||||
],
|
||||
|
@ -31,14 +31,13 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||
"k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
func TestMerge(t *testing.T) {
|
||||
grace := int64(30)
|
||||
enableServiceLinks := corev1.DefaultEnableServiceLinks
|
||||
tests := []struct {
|
||||
obj runtime.Object
|
||||
fragment string
|
||||
@ -60,14 +59,7 @@ func TestMerge(t *testing.T) {
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyAlways,
|
||||
DNSPolicy: corev1.DNSClusterFirst,
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SecurityContext: &corev1.PodSecurityContext{},
|
||||
SchedulerName: corev1.DefaultSchedulerName,
|
||||
EnableServiceLinks: &enableServiceLinks,
|
||||
},
|
||||
Spec: corev1.PodSpec{},
|
||||
},
|
||||
},
|
||||
/* TODO: uncomment this test once Merge is updated to use
|
||||
@ -127,20 +119,12 @@ func TestMerge(t *testing.T) {
|
||||
Spec: corev1.PodSpec{
|
||||
Volumes: []corev1.Volume{
|
||||
{
|
||||
Name: "v1",
|
||||
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
|
||||
Name: "v1",
|
||||
},
|
||||
{
|
||||
Name: "v2",
|
||||
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
|
||||
Name: "v2",
|
||||
},
|
||||
},
|
||||
RestartPolicy: corev1.RestartPolicyAlways,
|
||||
DNSPolicy: corev1.DNSClusterFirst,
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SecurityContext: &corev1.PodSecurityContext{},
|
||||
SchedulerName: corev1.DefaultSchedulerName,
|
||||
EnableServiceLinks: &enableServiceLinks,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -166,12 +150,9 @@ func TestMerge(t *testing.T) {
|
||||
APIVersion: "v1",
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
SessionAffinity: "None",
|
||||
Type: corev1.ServiceTypeClusterIP,
|
||||
Ports: []corev1.ServicePort{
|
||||
{
|
||||
Protocol: corev1.ProtocolTCP,
|
||||
Port: 0,
|
||||
Port: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -192,8 +173,6 @@ func TestMerge(t *testing.T) {
|
||||
APIVersion: "v1",
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
SessionAffinity: "None",
|
||||
Type: corev1.ServiceTypeClusterIP,
|
||||
Selector: map[string]string{
|
||||
"version": "v2",
|
||||
},
|
||||
@ -210,7 +189,7 @@ func TestMerge(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("testcase[%d], unexpected error: %v", i, err)
|
||||
} else if !apiequality.Semantic.DeepEqual(test.expected, out) {
|
||||
t.Errorf("\n\ntestcase[%d]\nexpected:\n%+v\nsaw:\n%+v", i, test.expected, out)
|
||||
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out))
|
||||
}
|
||||
}
|
||||
if test.expectErr && err == nil {
|
||||
|
@ -57,11 +57,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
legacyscheme.Scheme.AddKnownTypes(schema.GroupVersion{Group: "", Version: runtime.APIVersionInternal}, &TestPrintType{})
|
||||
legacyscheme.Scheme.AddKnownTypes(schema.GroupVersion{Group: "", Version: "v1"}, &TestPrintType{})
|
||||
}
|
||||
|
||||
var testData = TestStruct{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: "foo/bar", Kind: "TestStruct"},
|
||||
Key: "testValue",
|
||||
|
Loading…
Reference in New Issue
Block a user