(t *testing.T)
| 573 | } |
| 574 | |
| 575 | func TestGetCrawlerUser_HTTPError(t *testing.T) { |
| 576 | mux := http.NewServeMux() |
| 577 | mux.HandleFunc("/1/crawler/user", func(w http.ResponseWriter, r *http.Request) { |
| 578 | w.WriteHeader(http.StatusForbidden) |
| 579 | detail := "forbidden" |
| 580 | require.NoError(t, json.NewEncoder(w).Encode(DashboardCrawlerErrorResponse{ |
| 581 | Errors: []DashboardCrawlerError{{ |
| 582 | Status: http.StatusText(http.StatusForbidden), |
| 583 | Title: "Forbidden", |
| 584 | Detail: &detail, |
| 585 | }}, |
| 586 | })) |
| 587 | }) |
| 588 | |
| 589 | ts, client := newTestClient(mux) |
| 590 | defer ts.Close() |
| 591 | |
| 592 | _, err := client.GetCrawlerUser("test-token") |
| 593 | require.Error(t, err) |
| 594 | assert.Contains(t, err.Error(), "failed to get crawler user data: forbidden") |
| 595 | assert.NotContains(t, err.Error(), "403") |
| 596 | } |
| 597 | |
| 598 | func TestGetCrawlerUser_HTTPErrorWithoutDetail(t *testing.T) { |
| 599 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected