newServer stubs the dashboard PATCH endpoint, echoing the requested name back in the response so the command's success output can be asserted.
(t *testing.T)
| 30 | // newServer stubs the dashboard PATCH endpoint, echoing the requested name back |
| 31 | // in the response so the command's success output can be asserted. |
| 32 | func newServer(t *testing.T) *httptest.Server { |
| 33 | t.Helper() |
| 34 | mux := http.NewServeMux() |
| 35 | mux.HandleFunc("/1/applications/APP1", func(w http.ResponseWriter, r *http.Request) { |
| 36 | assert.Equal(t, http.MethodPatch, r.Method) |
| 37 | var payload dashboard.UpdateApplicationRequest |
| 38 | require.NoError(t, json.NewDecoder(r.Body).Decode(&payload)) |
| 39 | require.NoError(t, json.NewEncoder(w).Encode(dashboard.SingleApplicationResponse{ |
| 40 | Data: dashboard.ApplicationResource{ |
| 41 | ID: "APP1", |
| 42 | Type: "application", |
| 43 | Attributes: dashboard.ApplicationAttributes{ |
| 44 | ApplicationID: "APP1", |
| 45 | Name: payload.Name, |
| 46 | }, |
| 47 | }, |
| 48 | })) |
| 49 | }) |
| 50 | return httptest.NewServer(mux) |
| 51 | } |
| 52 | |
| 53 | func newOpts( |
| 54 | t *testing.T, |
no test coverage detected