Skip to content

Commit

Permalink
Update transport_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
CAFxX committed Feb 2, 2022
1 parent f8dec40 commit 7dc543b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions transport_test.go
Expand Up @@ -344,3 +344,25 @@ func TestRefreshTokenWithTrailingSlashBaseURL(t *testing.T) {
t.Fatalf("Unexpected RoundTrip response code: %d", res.StatusCode)
}
}

func TestRoundTripperContract(t *testing.T) {
tr := &Transport{
token: &accessToken{
ExpiresAt: time.Now().Add(1*time.Hour),
Token: "42",
},
tr: roundTripperFunc(func(req *http.Request) (*http.Response, error) {
if accept := req.Header.Get("Accept"); accept != "42" {
t.Errorf("got unexpected Accept request header in parent RoundTripper: %q", accept)
}
return nil, nil
}),
}
req := http.NewRequest("GET", "http://localhost", nil)
req.Header.Set("Accept", "xxx")
tr(req)
if accept := req.Header.Get("Accept"); accept != "xxx" {
t.Errorf("got unexpected Accept request header in caller: %q", accept)
}
}

0 comments on commit 7dc543b

Please sign in to comment.