Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,26 @@ func TestWithAuthToken(t *testing.T) {
t.Parallel()
validate(t, NewTokenClient(t.Context(), token).Client(), token)
})

t.Run("do not set Authorization when empty token", func(t *testing.T) {
t.Parallel()
c := new(Client).WithAuthToken("")

gotReq := false
ifAuthorizationSet := false
srv := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
gotReq = true
_, ifAuthorizationSet = r.Header["Authorization"]
}))
_, err := c.client.Get(srv.URL)
assertNilError(t, err)
if !gotReq {
t.Error("request not sent")
}
if ifAuthorizationSet {
t.Error("The header 'Authorization' must not be set")
}
})
}

func TestWithEnterpriseURLs(t *testing.T) {
Expand Down
Loading