Skip to content

Commit 6864b9a

Browse files
feat: implement channel update endpoint in mock server
1 parent a7b5642 commit 6864b9a

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

mocks/server/server.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,30 @@ func (s *MockServer) GetChannelsChannelId(w http.ResponseWriter, r *http.Request
142142
http.Error(w, "channel not found", http.StatusNotFound)
143143
}
144144

145+
func (s *MockServer) PutChannelsChannelId(w http.ResponseWriter, r *http.Request, channelId openapiTypes.UUID) {
146+
var request stdserver.UpdateChannel
147+
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
148+
http.Error(w, err.Error(), http.StatusBadRequest)
149+
return
150+
}
151+
152+
s.mu.Lock()
153+
defer s.mu.Unlock()
154+
155+
// Find and update the channel
156+
for i, ch := range s.channels {
157+
if ch.ChannelId == channelId {
158+
s.channels[i].Name = request.Name
159+
s.channels[i].Description = &request.Description
160+
w.Header().Set("Content-Type", "application/json")
161+
w.WriteHeader(http.StatusOK)
162+
_ = json.NewEncoder(w).Encode(s.channels[i])
163+
return
164+
}
165+
}
166+
http.Error(w, "channel not found", http.StatusNotFound)
167+
}
168+
145169
func (s *MockServer) DeleteChannelsChannelId(w http.ResponseWriter, r *http.Request, channelId openapiTypes.UUID) {
146170
s.mu.RLock()
147171
found := false

0 commit comments

Comments
 (0)