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,12 +20,8 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/parnurzeal/gorequest"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
|
|
@ -33,11 +29,11 @@ var _ = framework.IngressNginxDescribe("Dynamic $proxy_host", func() {
|
|||
test := "proxy-host"
|
||||
f := framework.NewDefaultFramework(test)
|
||||
|
||||
BeforeEach(func() {
|
||||
f.NewEchoDeploymentWithReplicas(1)
|
||||
ginkgo.BeforeEach(func() {
|
||||
f.NewEchoDeployment()
|
||||
})
|
||||
|
||||
It("should exist a proxy_host", func() {
|
||||
ginkgo.It("should exist a proxy_host", func() {
|
||||
upstreamName := fmt.Sprintf("%v-%v-80", f.Namespace, framework.EchoService)
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/configuration-snippet": `more_set_headers "Custom-Header: $proxy_host"`,
|
||||
|
|
@ -50,18 +46,15 @@ var _ = framework.IngressNginxDescribe("Dynamic $proxy_host", func() {
|
|||
strings.Contains(server, "set $proxy_host $proxy_upstream_name")
|
||||
})
|
||||
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||
Set("Host", test).
|
||||
End()
|
||||
|
||||
Expect(len(errs)).Should(Equal(0))
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
Expect(resp.Header.Get("Custom-Header")).Should(Equal(upstreamName))
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", test).
|
||||
Expect().
|
||||
Status(http.StatusOK).
|
||||
Header("Custom-Header").Equal(upstreamName)
|
||||
})
|
||||
|
||||
It("should exist a proxy_host using the upstream-vhost annotation value", func() {
|
||||
ginkgo.It("should exist a proxy_host using the upstream-vhost annotation value", func() {
|
||||
upstreamName := fmt.Sprintf("%v-%v-80", f.Namespace, framework.EchoService)
|
||||
upstreamVHost := "different.host"
|
||||
annotations := map[string]string{
|
||||
|
|
@ -76,14 +69,11 @@ var _ = framework.IngressNginxDescribe("Dynamic $proxy_host", func() {
|
|||
strings.Contains(server, fmt.Sprintf("set $proxy_host $proxy_upstream_name"))
|
||||
})
|
||||
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.GetURL(framework.HTTP)).
|
||||
Retry(10, 1*time.Second, http.StatusNotFound).
|
||||
Set("Host", test).
|
||||
End()
|
||||
|
||||
Expect(len(errs)).Should(Equal(0))
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
Expect(resp.Header.Get("Custom-Header")).Should(Equal(upstreamName))
|
||||
f.HTTPTestClient().
|
||||
GET("/").
|
||||
WithHeader("Host", test).
|
||||
Expect().
|
||||
Status(http.StatusOK).
|
||||
Header("Custom-Header").Equal(upstreamName)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue