oauth17_test.go 455 B

123456789101112131415161718192021222324
  1. // +build go1.7
  2. package oauth
  3. import (
  4. "context"
  5. "net/http"
  6. "net/http/httptest"
  7. "testing"
  8. )
  9. func TestGetContext_Cancel(t *testing.T) {
  10. ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  11. }))
  12. defer ts.Close()
  13. ctx, cancel := context.WithCancel(context.Background())
  14. cancel()
  15. c := Client{}
  16. _, err := c.GetContext(ctx, &Credentials{}, ts.URL, nil)
  17. if err == nil {
  18. t.Error("error should not be nil")
  19. }
  20. }