MCPcopy Create free account
hub / github.com/algolia/cli / TestGetCrawlerUser_HTTPError

Function TestGetCrawlerUser_HTTPError

api/dashboard/client_test.go:575–596  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

573}
574
575func 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
598func TestGetCrawlerUser_HTTPErrorWithoutDetail(t *testing.T) {
599 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
GetCrawlerUserMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected