Browse Source

more UnauthenticatedRateLimitedTransport tests

add test to check for required fields, as well as test for default vs
custom transport.
Will Norris 13 years ago
parent
commit
2e68086dfc
1 changed files with 41 additions and 0 deletions
  1. +41
    -0
      github/github_test.go

+ 41
- 0
github/github_test.go View File

@ -317,3 +317,44 @@ func TestUnauthenticatedRateLimitedTransport(t *testing.T) {
req, _ := unauthedClient.NewRequest("GET", "/", nil)
unauthedClient.Do(req, nil)
}
func TestUnauthenticatedRateLimitedTransport_missingFields(t *testing.T) {
// missing ClientID
tp := &UnauthenticatedRateLimitedTransport{
ClientSecret: "secret",
}
_, err := tp.RoundTrip(nil)
if err == nil {
t.Errorf("Expected error to be returned")
}
// missing ClientSecret
tp = &UnauthenticatedRateLimitedTransport{
ClientID: "id",
}
_, err = tp.RoundTrip(nil)
if err == nil {
t.Errorf("Expected error to be returned")
}
}
func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) {
// default transport
tp := &UnauthenticatedRateLimitedTransport{
ClientID: "id",
ClientSecret: "secret",
}
if tp.transport() != http.DefaultTransport {
t.Errorf("Expected http.DefaultTransport to be used.")
}
// custom transport
tp = &UnauthenticatedRateLimitedTransport{
ClientID: "id",
ClientSecret: "secret",
Transport: &http.Transport{},
}
if tp.transport() == http.DefaultTransport {
t.Errorf("Expected custom transport to be used.")
}
}

Loading…
Cancel
Save