Rename JSONBase -> TypeMeta in preparation for v1beta3
Will make subsequent refactor much easier
This commit is contained in:
@@ -366,7 +366,7 @@ func TestValidateManifest(t *testing.T) {
|
||||
|
||||
func TestValidatePod(t *testing.T) {
|
||||
errs := ValidatePod(&api.Pod{
|
||||
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -384,7 +384,7 @@ func TestValidatePod(t *testing.T) {
|
||||
t.Errorf("Unexpected non-zero error list: %#v", errs)
|
||||
}
|
||||
errs = ValidatePod(&api.Pod{
|
||||
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -397,7 +397,7 @@ func TestValidatePod(t *testing.T) {
|
||||
}
|
||||
|
||||
errs = ValidatePod(&api.Pod{
|
||||
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -424,7 +424,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing id",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -434,7 +434,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing namespace",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -444,7 +444,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid id",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "123abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -454,7 +454,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing port",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is missing/invalid.
|
||||
@@ -463,7 +463,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid port",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -473,7 +473,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid protocol",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -484,7 +484,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing selector",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
},
|
||||
// Should fail because the selector is missing.
|
||||
@@ -493,7 +493,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 1",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -503,7 +503,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 2",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -513,7 +513,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 3",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -530,7 +530,7 @@ func TestValidateService(t *testing.T) {
|
||||
|
||||
svc := api.Service{
|
||||
Port: 6502,
|
||||
JSONBase: api.JSONBase{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
}
|
||||
errs := ValidateService(&svc)
|
||||
@@ -555,14 +555,14 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
|
||||
successCases := []api.ReplicationController{
|
||||
{
|
||||
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
JSONBase: api.JSONBase{ID: "abc-123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc-123", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
@@ -577,40 +577,40 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
|
||||
errorCases := map[string]api.ReplicationController{
|
||||
"zero-length ID": {
|
||||
JSONBase: api.JSONBase{ID: "", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"missing-namespace": {
|
||||
JSONBase: api.JSONBase{ID: "abc-123"},
|
||||
TypeMeta: api.TypeMeta{ID: "abc-123"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"selector_doesnt_match": {
|
||||
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"foo": "bar"},
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"invalid manifest": {
|
||||
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
},
|
||||
},
|
||||
"negative_replicas": {
|
||||
JSONBase: api.JSONBase{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: -1,
|
||||
ReplicaSelector: validSelector,
|
||||
|
Reference in New Issue
Block a user