(t *testing.T)
| 264 | } |
| 265 | |
| 266 | func TestCreateApplication_Success(t *testing.T) { |
| 267 | mux := http.NewServeMux() |
| 268 | mux.HandleFunc("/1/applications", func(w http.ResponseWriter, r *http.Request) { |
| 269 | assert.Equal(t, http.MethodPost, r.Method) |
| 270 | assert.Equal(t, "Bearer test-token", r.Header.Get("Authorization")) |
| 271 | assert.Equal(t, "application/json", r.Header.Get("Content-Type")) |
| 272 | |
| 273 | var payload CreateApplicationRequest |
| 274 | require.NoError(t, json.NewDecoder(r.Body).Decode(&payload)) |
| 275 | assert.Equal(t, "us", payload.RegionCode) |
| 276 | assert.Equal(t, "My App", payload.Name) |
| 277 | |
| 278 | w.WriteHeader(http.StatusCreated) |
| 279 | require.NoError(t, json.NewEncoder(w).Encode(SingleApplicationResponse{ |
| 280 | Data: ApplicationResource{ |
| 281 | ID: "NEW_APP", Type: "application", |
| 282 | Attributes: ApplicationAttributes{ApplicationID: "NEW_APP", Name: "My App"}, |
| 283 | }, |
| 284 | })) |
| 285 | }) |
| 286 | |
| 287 | ts, client := newTestClient(mux) |
| 288 | defer ts.Close() |
| 289 | |
| 290 | app, err := client.CreateApplication("test-token", "us", "My App") |
| 291 | require.NoError(t, err) |
| 292 | assert.Equal(t, "NEW_APP", app.ID) |
| 293 | assert.Equal(t, "My App", app.Name) |
| 294 | } |
| 295 | |
| 296 | func TestUpdateApplication_Success(t *testing.T) { |
| 297 | mux := http.NewServeMux() |
nothing calls this directly
no test coverage detected