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

Function TestUpdateApplication_Success

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

Source from the content-addressed store, hash-verified

294}
295
296func 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
324func TestUpdateApplication_Unauthorized(t *testing.T) {
325 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 4

newTestClientFunction · 0.85
GetMethod · 0.80
UpdateApplicationMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected