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

Function newServer

pkg/cmd/application/update/update_test.go:32–51  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
32func 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
53func newOpts(
54 t *testing.T,

Callers 2

Test_runUpdateCmdFunction · 0.70

Calls 1

HelperMethod · 0.80

Tested by

no test coverage detected