add a 'protocol' field to api.Service
This commit is contained in:
@@ -408,6 +408,17 @@ func TestValidateService(t *testing.T) {
|
||||
// Should fail because the port number is invalid.
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "invalid protocol",
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123"},
|
||||
Port: 8675,
|
||||
Protocol: "INVALID",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
// Should fail because the protocol is invalid.
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "missing selector",
|
||||
svc: api.Service{
|
||||
@@ -422,6 +433,7 @@ func TestValidateService(t *testing.T) {
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123"},
|
||||
Port: 1,
|
||||
Protocol: "TCP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -431,6 +443,7 @@ func TestValidateService(t *testing.T) {
|
||||
svc: api.Service{
|
||||
JSONBase: api.JSONBase{ID: "abc123"},
|
||||
Port: 65535,
|
||||
Protocol: "UDP",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -452,6 +465,19 @@ func TestValidateService(t *testing.T) {
|
||||
t.Errorf("Unexpected error list for case %q: %+v", tc.name, errs)
|
||||
}
|
||||
}
|
||||
|
||||
svc := api.Service{
|
||||
Port: 6502,
|
||||
JSONBase: api.JSONBase{ID: "foo"},
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
}
|
||||
errs := ValidateService(&svc)
|
||||
if len(errs) != 0 {
|
||||
t.Errorf("Unexpected non-zero error list: %#v", errs)
|
||||
}
|
||||
if svc.Protocol != "TCP" {
|
||||
t.Errorf("Expected default protocol of 'TCP': %#v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateReplicationController(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user