mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
in pkg/kubelet/config/commont_test.go, remove check for v1beta1, add test cases for all registered version
This commit is contained in:
parent
b61658d064
commit
97b29c7fe6
@ -21,6 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/securitycontext"
|
||||||
|
|
||||||
@ -56,11 +57,6 @@ func TestDecodeSinglePod(t *testing.T) {
|
|||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
parsed, podOut, err := tryDecodeSinglePod(json, noDefault)
|
parsed, podOut, err := tryDecodeSinglePod(json, noDefault)
|
||||||
if testapi.Version() == "v1beta1" {
|
|
||||||
// v1beta1 conversion leaves empty lists that should be nil
|
|
||||||
podOut.Spec.Containers[0].Resources.Limits = nil
|
|
||||||
podOut.Spec.Containers[0].Resources.Requests = nil
|
|
||||||
}
|
|
||||||
if !parsed {
|
if !parsed {
|
||||||
t.Errorf("expected to have parsed file: (%s)", string(json))
|
t.Errorf("expected to have parsed file: (%s)", string(json))
|
||||||
}
|
}
|
||||||
@ -71,7 +67,8 @@ func TestDecodeSinglePod(t *testing.T) {
|
|||||||
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(json))
|
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(json))
|
||||||
}
|
}
|
||||||
|
|
||||||
externalPod, err := testapi.Converter().ConvertToVersion(pod, "v1beta3")
|
for _, version := range registered.RegisteredVersions {
|
||||||
|
externalPod, err := testapi.Converter().ConvertToVersion(pod, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -90,6 +87,7 @@ func TestDecodeSinglePod(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(pod, podOut) {
|
if !reflect.DeepEqual(pod, podOut) {
|
||||||
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(yaml))
|
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, podOut, string(yaml))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodePodList(t *testing.T) {
|
func TestDecodePodList(t *testing.T) {
|
||||||
@ -137,7 +135,8 @@ func TestDecodePodList(t *testing.T) {
|
|||||||
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", podList, &podListOut, string(json))
|
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", podList, &podListOut, string(json))
|
||||||
}
|
}
|
||||||
|
|
||||||
externalPodList, err := testapi.Converter().ConvertToVersion(podList, "v1beta3")
|
for _, version := range registered.RegisteredVersions {
|
||||||
|
externalPodList, err := testapi.Converter().ConvertToVersion(podList, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -156,4 +155,5 @@ func TestDecodePodList(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(podList, &podListOut) {
|
if !reflect.DeepEqual(podList, &podListOut) {
|
||||||
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, &podListOut, string(yaml))
|
t.Errorf("expected:\n%#v\ngot:\n%#v\n%s", pod, &podListOut, string(yaml))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user