mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Fixed and added tests
This commit is contained in:
@@ -26,19 +26,22 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/apimachinery/registered"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
|
||||
_ "k8s.io/kubernetes/pkg/api/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/componentconfig/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/metrics/install"
|
||||
)
|
||||
|
||||
var (
|
||||
Groups = make(map[string]TestGroup)
|
||||
Default TestGroup
|
||||
Extensions TestGroup
|
||||
Groups = make(map[string]TestGroup)
|
||||
Default TestGroup
|
||||
Autoscaling TestGroup
|
||||
Extensions TestGroup
|
||||
)
|
||||
|
||||
type TestGroup struct {
|
||||
@@ -69,6 +72,12 @@ func init() {
|
||||
internalGroupVersion: api.SchemeGroupVersion,
|
||||
}
|
||||
}
|
||||
if _, ok := Groups[autoscaling.GroupName]; !ok {
|
||||
Groups[autoscaling.GroupName] = TestGroup{
|
||||
externalGroupVersion: unversioned.GroupVersion{Group: autoscaling.GroupName, Version: registered.GroupOrDie(autoscaling.GroupName).GroupVersion.Version},
|
||||
internalGroupVersion: autoscaling.SchemeGroupVersion,
|
||||
}
|
||||
}
|
||||
if _, ok := Groups[extensions.GroupName]; !ok {
|
||||
Groups[extensions.GroupName] = TestGroup{
|
||||
externalGroupVersion: unversioned.GroupVersion{Group: extensions.GroupName, Version: registered.GroupOrDie(extensions.GroupName).GroupVersion.Version},
|
||||
@@ -77,6 +86,7 @@ func init() {
|
||||
}
|
||||
|
||||
Default = Groups[api.GroupName]
|
||||
Autoscaling = Groups[autoscaling.GroupName]
|
||||
Extensions = Groups[extensions.GroupName]
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,8 @@ func TestV1EncodeDecodeStatus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExperimentalEncodeDecodeStatus(t *testing.T) {
|
||||
extensionCodec := Extensions.Codec()
|
||||
encoded, err := runtime.Encode(extensionCodec, status)
|
||||
func testEncodeDecodeStatus(t *testing.T, codec runtime.Codec) {
|
||||
encoded, err := runtime.Encode(codec, status)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -116,7 +115,7 @@ func TestExperimentalEncodeDecodeStatus(t *testing.T) {
|
||||
if typeMeta.APIVersion != "v1" {
|
||||
t.Errorf("APIVersion is not set to \"\". Got %s", encoded)
|
||||
}
|
||||
decoded, err := runtime.Decode(extensionCodec, encoded)
|
||||
decoded, err := runtime.Decode(codec, encoded)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -124,3 +123,11 @@ func TestExperimentalEncodeDecodeStatus(t *testing.T) {
|
||||
t.Errorf("expected: %v, got: %v", status, decoded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoscalingEncodeDecodeStatus(t *testing.T) {
|
||||
testEncodeDecodeStatus(t, Autoscaling.Codec())
|
||||
}
|
||||
|
||||
func TestExperimentalEncodeDecodeStatus(t *testing.T) {
|
||||
testEncodeDecodeStatus(t, Extensions.Codec())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user