(t *testing.T)
| 596 | } |
| 597 | |
| 598 | func TestGetCrawlerUser_HTTPErrorWithoutDetail(t *testing.T) { |
| 599 | mux := http.NewServeMux() |
| 600 | mux.HandleFunc("/1/crawler/user", func(w http.ResponseWriter, r *http.Request) { |
| 601 | w.WriteHeader(http.StatusForbidden) |
| 602 | require.NoError(t, json.NewEncoder(w).Encode(DashboardCrawlerErrorResponse{ |
| 603 | Errors: []DashboardCrawlerError{{ |
| 604 | Status: http.StatusText(http.StatusForbidden), |
| 605 | Title: "Forbidden", |
| 606 | Detail: nil, |
| 607 | }}, |
| 608 | })) |
| 609 | }) |
| 610 | |
| 611 | ts, client := newTestClient(mux) |
| 612 | defer ts.Close() |
| 613 | |
| 614 | _, err := client.GetCrawlerUser("test-token") |
| 615 | require.Error(t, err) |
| 616 | assert.Contains(t, err.Error(), "failed to get crawler user data: Forbidden") |
| 617 | assert.NotContains(t, err.Error(), "403") |
| 618 | } |
| 619 | |
| 620 | func TestGetCrawlerUser_InvalidJSON(t *testing.T) { |
| 621 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected