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

Function TestChangeApplicationPlan_Success

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

Source from the content-addressed store, hash-verified

459}
460
461func TestChangeApplicationPlan_Success(t *testing.T) {
462 mux := http.NewServeMux()
463 mux.HandleFunc(
464 "/1/applications/APP1/plan/self-serve",
465 func(w http.ResponseWriter, r *http.Request) {
466 assert.Equal(t, http.MethodPatch, r.Method)
467 assert.Equal(t, "Bearer test-token", r.Header.Get("Authorization"))
468 assert.Equal(t, "application/json", r.Header.Get("Content-Type"))
469
470 var payload ChangePlanRequest
471 require.NoError(t, json.NewDecoder(r.Body).Decode(&payload))
472 assert.Equal(t, "grow", payload.Plan)
473
474 require.NoError(t, json.NewEncoder(w).Encode(SingleApplicationResponse{
475 Data: ApplicationResource{
476 ID: "APP1", Type: "application",
477 Attributes: ApplicationAttributes{ApplicationID: "APP1", Name: "My App"},
478 },
479 }))
480 },
481 )
482
483 ts, client := newTestClient(mux)
484 defer ts.Close()
485
486 app, err := client.ChangeApplicationPlan("test-token", "APP1", "grow")
487 require.NoError(t, err)
488 assert.Equal(t, "APP1", app.ID)
489 assert.Equal(t, "My App", app.Name)
490}
491
492func TestChangeApplicationPlan_EmptyBodyFallback(t *testing.T) {
493 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
GetMethod · 0.80
ChangeApplicationPlanMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected