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

Function TestGetCrawlerUser_HTTPErrorWithoutDetail

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

Source from the content-addressed store, hash-verified

596}
597
598func 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
620func TestGetCrawlerUser_InvalidJSON(t *testing.T) {
621 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