Refactor e2e tests to use testify y httpexpect
This commit is contained in:
parent
046e2d959d
commit
f9624cbe46
80 changed files with 2280 additions and 2631 deletions
|
|
@ -20,10 +20,8 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/parnurzeal/gorequest"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
networking "k8s.io/api/networking/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
|
@ -34,7 +32,7 @@ import (
|
|||
var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
||||
f := framework.NewDefaultFramework("disabled-catch-all")
|
||||
|
||||
BeforeEach(func() {
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeploymentWithReplicas(1)
|
||||
|
||||
err := framework.UpdateDeployment(f.KubeClientSet, f.Namespace, "nginx-ingress-controller", 1,
|
||||
|
|
@ -46,10 +44,10 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
|||
|
||||
return err
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred(), "unexpected error updating ingress controller deployment flags")
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "updating ingress controller deployment flags")
|
||||
})
|
||||
|
||||
It("should ignore catch all Ingress", func() {
|
||||
ginkgo.It("should ignore catch all Ingress", func() {
|
||||
host := "foo"
|
||||
|
||||
ing := framework.NewSingleCatchAllIngress("catch-all", f.Namespace, framework.EchoService, 80, nil)
|
||||
|
|
@ -68,7 +66,7 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
|||
})
|
||||
})
|
||||
|
||||
It("should delete Ingress updated to catch-all", func() {
|
||||
ginkgo.It("should delete Ingress updated to catch-all", func() {
|
||||
host := "foo"
|
||||
|
||||
ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.EchoService, 80, nil)
|
||||
|
|
@ -79,12 +77,11 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
|||
return strings.Contains(server, "server_name foo")
|
||||
})
|
||||
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Set("Host", host).
|
||||
End()
|
||||
Expect(errs).To(BeNil())
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusOK)
|
||||
|
||||
err := framework.UpdateIngress(f.KubeClientSet, f.Namespace, host, func(ingress *networking.Ingress) error {
|
||||
ingress.Spec.Rules = nil
|
||||
|
|
@ -94,21 +91,20 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
|||
}
|
||||
return nil
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
assert.Nil(ginkgo.GinkgoT(), err)
|
||||
|
||||
f.WaitForNginxConfiguration(func(cfg string) bool {
|
||||
return !strings.Contains(cfg, "server_name foo")
|
||||
})
|
||||
|
||||
resp, _, errs = gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Set("Host", host).
|
||||
End()
|
||||
Expect(errs).To(BeNil())
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusNotFound))
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusNotFound)
|
||||
})
|
||||
|
||||
It("should allow Ingress with both a default backend and rules", func() {
|
||||
ginkgo.It("should allow Ingress with both a default backend and rules", func() {
|
||||
host := "foo"
|
||||
|
||||
ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.Namespace, framework.EchoService, 80, framework.EchoService, 80, nil)
|
||||
|
|
@ -118,13 +114,10 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
|
|||
return strings.Contains(cfg, "server_name foo")
|
||||
})
|
||||
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Set("Host", host).
|
||||
End()
|
||||
|
||||
Expect(errs).To(BeNil())
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", host).
|
||||
Expect().
|
||||
Status(http.StatusOK)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue