(t *testing.T)
| 459 | } |
| 460 | |
| 461 | func 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 | |
| 492 | func TestChangeApplicationPlan_EmptyBodyFallback(t *testing.T) { |
| 493 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected