From 752eceed4bb8a0d0eee9e211a1dbb27190c671e9 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Fri, 10 May 2019 11:53:12 +0300 Subject: [PATCH] Add tests for ingress weight changes --- pkg/router/ingress_test.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/pkg/router/ingress_test.go b/pkg/router/ingress_test.go index 1fda7cd5..7d2679e6 100644 --- a/pkg/router/ingress_test.go +++ b/pkg/router/ingress_test.go @@ -79,7 +79,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { t.Errorf("Canary annotation missing") } - // test initialisation + // test rollout if inCanary.Annotations[canaryAn] != "true" { t.Errorf("Got canary annotation %v wanted true", inCanary.Annotations[canaryAn]) } @@ -87,4 +87,26 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { if inCanary.Annotations[canaryWeightAn] != "50" { t.Errorf("Got canary weight annotation %v wanted 50", inCanary.Annotations[canaryWeightAn]) } + + p = 100 + c = 0 + + err = router.SetRoutes(mocks.ingressCanary, p, c) + if err != nil { + t.Fatal(err.Error()) + } + + inCanary, err = router.kubeClient.ExtensionsV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{}) + if err != nil { + t.Fatal(err.Error()) + } + + // test promotion + if inCanary.Annotations[canaryAn] != "false" { + t.Errorf("Got canary annotation %v wanted false", inCanary.Annotations[canaryAn]) + } + + if inCanary.Annotations[canaryWeightAn] != "0" { + t.Errorf("Got canary weight annotation %v wanted 0", inCanary.Annotations[canaryWeightAn]) + } }