Skip to content

Commit e2a2e26

Browse files
vitolkachovapjcdawkins
authored andcommitted
add mock deploy call
1 parent c705786 commit e2a2e26

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pkg/mockapi/api_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func NewHandler(t *testing.T) *Handler {
7070
h.Mux.Get("/projects/{project_id}/environments", h.handleListEnvironments)
7171
h.Mux.Get("/projects/{project_id}/environments/{environment_id}", h.handleGetEnvironment)
7272
h.Mux.Patch("/projects/{project_id}/environments/{environment_id}", h.handlePatchEnvironment)
73+
h.Mux.Post("/projects/{project_id}/environments/{environment_id}/deploy", h.handleDeployEnvironment)
7374
h.Mux.Get("/projects/{project_id}/environments/{environment_id}/backups", h.handleListBackups)
7475
h.Mux.Post("/projects/{project_id}/environments/{environment_id}/backups", h.handleCreateBackup)
7576
h.Mux.Get("/projects/{project_id}/environments/{environment_id}/deployments/current", h.handleGetCurrentDeployment)

pkg/mockapi/environments.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ func (h *Handler) handlePatchEnvironment(w http.ResponseWriter, req *http.Reques
6060
_ = json.NewEncoder(w).Encode(&patched)
6161
}
6262

63+
func (h *Handler) handleDeployEnvironment(w http.ResponseWriter, req *http.Request) {
64+
env := h.findEnvironment(chi.URLParam(req, "project_id"), chi.URLParam(req, "environment_id"))
65+
if env == nil {
66+
w.WriteHeader(http.StatusNotFound)
67+
return
68+
}
69+
70+
_ = json.NewEncoder(w).Encode(map[string]any{
71+
"_embedded": map[string]any{"activities": []Activity{}},
72+
})
73+
}
74+
6375
func (h *Handler) handleGetCurrentDeployment(w http.ResponseWriter, req *http.Request) {
6476
h.store.RLock()
6577
defer h.store.RUnlock()

0 commit comments

Comments
 (0)