Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Schneider committed Jan 20, 2021
1 parent 442a1c4 commit 162a874
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,31 @@ func TestHTTPServer_QueryEncoding(t *testing.T) {
shutdown()
}

func TestHTTPServer_Backends(t *testing.T) {
client := newClient()

config := "testdata/integration/config/02_couper.hcl"

shutdown, _ := newCouper(config, test.New(t))

t.Run("Query-Encoding", func(subT *testing.T) {
helper := test.New(subT)

req, err := http.NewRequest(http.MethodGet, "http://example.com:8080", nil)
helper.Must(err)

res, err := client.Do(req)
helper.Must(err)

exp := []string{"1", "2", "3", "4"}
if !reflect.DeepEqual(res.Header.Values("Foo"), exp) {
t.Errorf("\nwant: \n%#v\ngot: \n%#v", exp, res.Header.Values("Foo"))
}
})

shutdown()
}

func TestHTTPServer_TrailingSlash(t *testing.T) {
client := newClient()

Expand Down
33 changes: 33 additions & 0 deletions server/testdata/integration/config/02_couper.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server "backends" {
backend "test" {
add_response_headers = {
foo = "2"
}
}

api {
backend "test" {
add_response_headers = {
foo = "3"
}
}

endpoint "/" {
backend "test" {
add_response_headers = {
foo = "4"
}
}
}
}
}

definitions {
backend "test" {
origin = env.COUPER_TEST_BACKEND_ADDR

set_response_headers = {
foo = "1"
}
}
}

0 comments on commit 162a874

Please sign in to comment.