Rename ID -> Name
This commit is contained in:
@@ -367,7 +367,7 @@ func TestValidateManifest(t *testing.T) {
|
||||
|
||||
func TestValidatePod(t *testing.T) {
|
||||
errs := ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -385,7 +385,7 @@ func TestValidatePod(t *testing.T) {
|
||||
t.Errorf("Unexpected non-zero error list: %#v", errs)
|
||||
}
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -398,7 +398,7 @@ func TestValidatePod(t *testing.T) {
|
||||
}
|
||||
|
||||
errs = ValidatePod(&api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -426,23 +426,23 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
{api.Pod{}, api.Pod{}, true, "nothing"},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "bar"},
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
},
|
||||
false,
|
||||
"ids",
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Labels: map[string]string{
|
||||
"bar": "foo",
|
||||
},
|
||||
@@ -452,7 +452,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -464,7 +464,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -483,7 +483,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -495,7 +495,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -511,7 +511,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -524,7 +524,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -541,7 +541,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -556,7 +556,7 @@ func TestValidatePodUpdate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
api.Pod{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Containers: []api.Container{
|
||||
@@ -608,7 +608,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing namespace",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "foo"},
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -618,7 +618,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid id",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "123abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "123abc", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -628,7 +628,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the port number is missing/invalid.
|
||||
@@ -637,7 +637,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid port",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65536,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -647,7 +647,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "invalid protocol",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -658,7 +658,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "missing selector",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Port: 8675,
|
||||
},
|
||||
// Should fail because the selector is missing.
|
||||
@@ -667,7 +667,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 1",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -677,7 +677,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 2",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
@@ -687,7 +687,7 @@ func TestValidateService(t *testing.T) {
|
||||
{
|
||||
name: "valid 3",
|
||||
svc: api.Service{
|
||||
TypeMeta: api.TypeMeta{ID: "abc123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc123", Namespace: api.NamespaceDefault},
|
||||
Port: 80,
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
@@ -704,7 +704,7 @@ func TestValidateService(t *testing.T) {
|
||||
|
||||
svc := api.Service{
|
||||
Port: 6502,
|
||||
TypeMeta: api.TypeMeta{ID: "foo", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
}
|
||||
errs := ValidateService(&svc)
|
||||
@@ -736,14 +736,14 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
}
|
||||
successCases := []api.ReplicationController{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
{
|
||||
TypeMeta: api.TypeMeta{ID: "abc-123", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
@@ -758,47 +758,47 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
|
||||
errorCases := map[string]api.ReplicationController{
|
||||
"zero-length ID": {
|
||||
TypeMeta: api.TypeMeta{ID: "", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"missing-namespace": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc-123"},
|
||||
TypeMeta: api.TypeMeta{Name: "abc-123"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"selector_doesnt_match": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: map[string]string{"foo": "bar"},
|
||||
PodTemplate: validPodTemplate,
|
||||
},
|
||||
},
|
||||
"invalid manifest": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
},
|
||||
},
|
||||
"read-write presistent disk": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc"},
|
||||
TypeMeta: api.TypeMeta{Name: "abc"},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
ReplicaSelector: validSelector,
|
||||
PodTemplate: invalidVolumePodTemplate,
|
||||
},
|
||||
},
|
||||
"negative_replicas": {
|
||||
TypeMeta: api.TypeMeta{ID: "abc", Namespace: api.NamespaceDefault},
|
||||
TypeMeta: api.TypeMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: -1,
|
||||
ReplicaSelector: validSelector,
|
||||
@@ -827,13 +827,13 @@ func TestValidateReplicationController(t *testing.T) {
|
||||
func TestValidateBoundPodNoName(t *testing.T) {
|
||||
errorCases := map[string]api.BoundPod{
|
||||
// manifest is tested in api/validation_test.go, ensure it is invoked
|
||||
"empty version": {TypeMeta: api.TypeMeta{ID: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
"empty version": {TypeMeta: api.TypeMeta{Name: "test"}, Spec: api.PodSpec{Containers: []api.Container{{Name: ""}}}},
|
||||
|
||||
// Name
|
||||
"zero-length name": {TypeMeta: api.TypeMeta{ID: ""}},
|
||||
"name > 255 characters": {TypeMeta: api.TypeMeta{ID: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {TypeMeta: api.TypeMeta{ID: "a.b.c."}},
|
||||
"name with underscore": {TypeMeta: api.TypeMeta{ID: "a_b_c"}},
|
||||
"zero-length name": {TypeMeta: api.TypeMeta{Name: ""}},
|
||||
"name > 255 characters": {TypeMeta: api.TypeMeta{Name: strings.Repeat("a", 256)}},
|
||||
"name not a DNS subdomain": {TypeMeta: api.TypeMeta{Name: "a.b.c."}},
|
||||
"name with underscore": {TypeMeta: api.TypeMeta{Name: "a_b_c"}},
|
||||
}
|
||||
for k, v := range errorCases {
|
||||
if errs := ValidateBoundPod(&v); len(errs) == 0 {
|
||||
|
Reference in New Issue
Block a user