Add test
Signed-off-by: Alejandro Pedraza <alejandro.pedraza@gmail.com>
This commit is contained in:
parent
a3c87cf9cb
commit
7ea245e6e6
1 changed files with 33 additions and 4 deletions
|
@ -832,16 +832,17 @@ func TestOpentracingPropagateContext(t *testing.T) {
|
||||||
func TestGetIngressInformation(t *testing.T) {
|
func TestGetIngressInformation(t *testing.T) {
|
||||||
validIngress := &ingress.Ingress{}
|
validIngress := &ingress.Ingress{}
|
||||||
invalidIngress := "wrongtype"
|
invalidIngress := "wrongtype"
|
||||||
|
host := "host1"
|
||||||
validPath := "/ok"
|
validPath := "/ok"
|
||||||
invalidPath := 10
|
invalidPath := 10
|
||||||
|
|
||||||
info := getIngressInformation(invalidIngress, validPath)
|
info := getIngressInformation(invalidIngress, host, validPath)
|
||||||
expected := &ingressInformation{}
|
expected := &ingressInformation{}
|
||||||
if !info.Equal(expected) {
|
if !info.Equal(expected) {
|
||||||
t.Errorf("Expected %v, but got %v", expected, info)
|
t.Errorf("Expected %v, but got %v", expected, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
info = getIngressInformation(validIngress, invalidPath)
|
info = getIngressInformation(validIngress, host, invalidPath)
|
||||||
if !info.Equal(expected) {
|
if !info.Equal(expected) {
|
||||||
t.Errorf("Expected %v, but got %v", expected, info)
|
t.Errorf("Expected %v, but got %v", expected, info)
|
||||||
}
|
}
|
||||||
|
@ -856,7 +857,7 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
ServiceName: "a-svc",
|
ServiceName: "a-svc",
|
||||||
}
|
}
|
||||||
|
|
||||||
info = getIngressInformation(validIngress, validPath)
|
info = getIngressInformation(validIngress, host, validPath)
|
||||||
expected = &ingressInformation{
|
expected = &ingressInformation{
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Rule: "validIng",
|
Rule: "validIng",
|
||||||
|
@ -872,6 +873,7 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
validIngress.Spec.Backend = nil
|
validIngress.Spec.Backend = nil
|
||||||
validIngress.Spec.Rules = []extensions.IngressRule{
|
validIngress.Spec.Rules = []extensions.IngressRule{
|
||||||
{
|
{
|
||||||
|
Host: host,
|
||||||
IngressRuleValue: extensions.IngressRuleValue{
|
IngressRuleValue: extensions.IngressRuleValue{
|
||||||
HTTP: &extensions.HTTPIngressRuleValue{
|
HTTP: &extensions.HTTPIngressRuleValue{
|
||||||
Paths: []extensions.HTTPIngressPath{
|
Paths: []extensions.HTTPIngressPath{
|
||||||
|
@ -888,7 +890,7 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
{},
|
{},
|
||||||
}
|
}
|
||||||
|
|
||||||
info = getIngressInformation(validIngress, validPath)
|
info = getIngressInformation(validIngress, host, validPath)
|
||||||
expected = &ingressInformation{
|
expected = &ingressInformation{
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Rule: "validIng",
|
Rule: "validIng",
|
||||||
|
@ -900,6 +902,33 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
if !info.Equal(expected) {
|
if !info.Equal(expected) {
|
||||||
t.Errorf("Expected %v, but got %v", expected, info)
|
t.Errorf("Expected %v, but got %v", expected, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validIngress.Spec.Rules = append(validIngress.Spec.Rules, extensions.IngressRule{
|
||||||
|
Host: "host2",
|
||||||
|
IngressRuleValue: extensions.IngressRuleValue{
|
||||||
|
HTTP: &extensions.HTTPIngressRuleValue{
|
||||||
|
Paths: []extensions.HTTPIngressPath{
|
||||||
|
{
|
||||||
|
Path: "/ok",
|
||||||
|
Backend: extensions.IngressBackend{
|
||||||
|
ServiceName: "c-svc",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
info = getIngressInformation(validIngress, host, validPath)
|
||||||
|
if !info.Equal(expected) {
|
||||||
|
t.Errorf("Expected %v, but got %v", expected, info)
|
||||||
|
}
|
||||||
|
|
||||||
|
info = getIngressInformation(validIngress, "host2", validPath)
|
||||||
|
expected.Service = "c-svc"
|
||||||
|
if !info.Equal(expected) {
|
||||||
|
t.Errorf("Expected %v, but got %v", expected, info)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildCustomErrorLocationsPerServer(t *testing.T) {
|
func TestBuildCustomErrorLocationsPerServer(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue