Skip to content

Commit

Permalink
Add tests for setting headers
Browse files Browse the repository at this point in the history
  • Loading branch information
bentranter committed Dec 2, 2020
1 parent 8c2ad8c commit 024460f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions godo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,28 @@ func TestNewRequest_withCustomUserAgent(t *testing.T) {
}
}

func TestNewRequest_withCustomHeaders(t *testing.T) {
expectedIdentity := "identity"
expectedCustom := "x_test_header"

c, err := New(nil, SetRequestHeaders(map[string]string{
"Accept-Encoding": expectedIdentity,
"X-Test-Header": expectedCustom,
}))
if err != nil {
t.Fatalf("New() unexpected error: %v", err)
}

req, _ := c.NewRequest(ctx, http.MethodGet, "/foo", nil)

if got := req.Header.Get("Accept-Encoding"); got != expectedIdentity {
t.Errorf("New() Custom Accept Encoding Header = %s; expected %s", got, expectedIdentity)
}
if got := req.Header.Get("X-Test-Header"); got != expectedCustom {
t.Errorf("New() Custom Accept Encoding Header = %s; expected %s", got, expectedCustom)
}
}

func TestDo(t *testing.T) {
setup()
defer teardown()
Expand Down

0 comments on commit 024460f

Please sign in to comment.