(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestAuthErrWithoutBody(t *testing.T) { |
| 104 | var called uint32 |
| 105 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 106 | if r.URL.String() != "/test" { |
| 107 | w.WriteHeader(http.StatusNotFound) |
| 108 | return |
| 109 | } |
| 110 | |
| 111 | atomic.AddUint32(&called, 1) |
| 112 | w.WriteHeader(401) |
| 113 | })) |
| 114 | defer srv.Close() |
| 115 | |
| 116 | req, err := http.NewRequest("GET", srv.URL+"/test", nil) |
| 117 | assert.Nil(t, err) |
| 118 | |
| 119 | c, _ := NewClient(nil) |
| 120 | _, err = c.Do(req) |
| 121 | assert.NotNil(t, err) |
| 122 | assert.True(t, errors.IsAuthError(err)) |
| 123 | assert.True(t, strings.HasPrefix(err.Error(), "Authentication required: Authorization error:"), err.Error()) |
| 124 | assert.EqualValues(t, 1, called) |
| 125 | } |
| 126 | |
| 127 | func TestFatalWithoutBody(t *testing.T) { |
| 128 | var called uint32 |
nothing calls this directly
no test coverage detected