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

Function TestChangeApplicationPlan_ErrorStatus

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

Source from the content-addressed store, hash-verified

525}
526
527func TestChangeApplicationPlan_ErrorStatus(t *testing.T) {
528 mux := http.NewServeMux()
529 mux.HandleFunc(
530 "/1/applications/APP1/plan/self-serve",
531 func(w http.ResponseWriter, r *http.Request) {
532 w.WriteHeader(http.StatusUnprocessableEntity)
533 _, err := w.Write([]byte(`{"errors":[{"title":"plan change not allowed"}]}`))
534 require.NoError(t, err)
535 },
536 )
537
538 ts, client := newTestClient(mux)
539 defer ts.Close()
540
541 _, err := client.ChangeApplicationPlan("test-token", "APP1", "grow")
542 require.Error(t, err)
543 assert.Contains(t, err.Error(), "Couldn't change your application's plan: 422")
544 // The response body must never be surfaced in the error, only the status.
545 assert.NotContains(t, err.Error(), "plan change not allowed")
546}
547
548func TestGetCrawlerUser_Success(t *testing.T) {
549 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected