(t *testing.T)
| 294 | } |
| 295 | |
| 296 | func TestUpdateApplication_Success(t *testing.T) { |
| 297 | mux := http.NewServeMux() |
| 298 | mux.HandleFunc("/1/applications/APP1", func(w http.ResponseWriter, r *http.Request) { |
| 299 | assert.Equal(t, http.MethodPatch, r.Method) |
| 300 | assert.Equal(t, "Bearer test-token", r.Header.Get("Authorization")) |
| 301 | assert.Equal(t, "application/json", r.Header.Get("Content-Type")) |
| 302 | |
| 303 | var payload UpdateApplicationRequest |
| 304 | require.NoError(t, json.NewDecoder(r.Body).Decode(&payload)) |
| 305 | assert.Equal(t, "Renamed App", payload.Name) |
| 306 | |
| 307 | require.NoError(t, json.NewEncoder(w).Encode(SingleApplicationResponse{ |
| 308 | Data: ApplicationResource{ |
| 309 | ID: "APP1", Type: "application", |
| 310 | Attributes: ApplicationAttributes{ApplicationID: "APP1", Name: "Renamed App"}, |
| 311 | }, |
| 312 | })) |
| 313 | }) |
| 314 | |
| 315 | ts, client := newTestClient(mux) |
| 316 | defer ts.Close() |
| 317 | |
| 318 | app, err := client.UpdateApplication("test-token", "APP1", "Renamed App") |
| 319 | require.NoError(t, err) |
| 320 | assert.Equal(t, "APP1", app.ID) |
| 321 | assert.Equal(t, "Renamed App", app.Name) |
| 322 | } |
| 323 | |
| 324 | func TestUpdateApplication_Unauthorized(t *testing.T) { |
| 325 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected