add test for flipServiceInternalAnnotation

This commit is contained in:
Jingtao Ren 2017-11-16 16:32:02 -08:00
parent 1b9b3fd7c7
commit 839e7f4c38

View File

@ -40,6 +40,30 @@ import (
var testClusterName = "testCluster"
// Test flipServiceInternalAnnotation
func TestFlipServiceInternalAnnotation(t *testing.T) {
svc := getTestService("servicea", v1.ProtocolTCP, 80)
svcUpdated := flipServiceInternalAnnotation(&svc)
if !requiresInternalLoadBalancer(svcUpdated) {
t.Errorf("Expected svc to be an internal service")
}
svcUpdated = flipServiceInternalAnnotation(svcUpdated)
if requiresInternalLoadBalancer(svcUpdated) {
t.Errorf("Expected svc to be an external service")
}
svc2 := getInternalTestService("serviceb", 8081)
svc2Updated := flipServiceInternalAnnotation(&svc2)
if requiresInternalLoadBalancer(svc2Updated) {
t.Errorf("Expected svc to be an external service")
}
svc2Updated = flipServiceInternalAnnotation(svc2Updated)
if !requiresInternalLoadBalancer(svc2Updated) {
t.Errorf("Expected svc to be an internal service")
}
}
// Test additional of a new service/port.
func TestAddPort(t *testing.T) {
az := getTestCloud()