Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
keks committed Oct 2, 2018
1 parent a22254b commit f493069
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import (

func TestHTTP(t *testing.T) {
type testcase struct {
path []string
v interface{}
vs []interface{}
file files.File
r string
err error
sendErr error
wait bool
path []string
v interface{}
vs []interface{}
file files.File
r string
err error
sendErr error
wait bool
expectHeader map[string]string
}

tcs := []testcase{
Expand Down Expand Up @@ -74,6 +75,9 @@ func TestHTTP(t *testing.T) {
Closer: nopCloser{},
}, nil)}),
vs: []interface{}{"i received:", "This is the body of the request!"},
expectHeader: map[string]string{
"Connection": "close",
},
},
}

Expand Down Expand Up @@ -201,6 +205,13 @@ func TestHTTP(t *testing.T) {
}
}

httpRes := res.(*Response)
for h, hexp := range tc.expectHeader {
hdr := httpRes.res.Header.Get(h)
if hdr != hexp {
t.Errorf("expected header %q to be %q but got %q", h, hexp, hdr)
}
}
wait, ok := getWaitChan(env)
if !ok {
t.Fatal("could not get wait chan")
Expand Down

0 comments on commit f493069

Please sign in to comment.