(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestHTTPProvider_ServerError(t *testing.T) { |
| 61 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 62 | w.WriteHeader(http.StatusInternalServerError) |
| 63 | })) |
| 64 | defer srv.Close() |
| 65 | |
| 66 | p, _ := newTestHTTPProvider(t, srv.URL+"/config.yaml", &http.Client{}) |
| 67 | |
| 68 | _, err := p.Read(context.Background()) |
| 69 | require.Error(t, err) |
| 70 | assert.Contains(t, err.Error(), "HTTP 500") |
| 71 | |
| 72 | var httpErr *httpError |
| 73 | require.ErrorAs(t, err, &httpErr) |
| 74 | assert.Equal(t, 500, httpErr.statusCode) |
| 75 | |
| 76 | assert.Equal(t, 1, testutil.CollectAndCount(p.requestDuration)) |
| 77 | } |
| 78 | |
| 79 | func TestHTTPProvider_NonOKStatus(t *testing.T) { |
| 80 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
nothing calls this directly
no test coverage detected