feat(agents): align duplicate create errors
This commit is contained in:
@@ -190,10 +190,14 @@ func (s *AgentHandlerTestSuite) TestCreateAgentDuplicate() {
|
||||
s.handler.Create(c)
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
|
||||
// Try creating again — should conflict
|
||||
// Try creating again — Chatwoot renders ActiveRecord::RecordInvalid as 422.
|
||||
w2, c2 := s.makeRequest("POST", "/api/v1/accounts/1/agents", req, s.account.ID, s.user.ID)
|
||||
s.handler.Create(c2)
|
||||
assert.Equal(s.T(), http.StatusConflict, w2.Code)
|
||||
assert.Equal(s.T(), http.StatusUnprocessableEntity, w2.Code)
|
||||
var data map[string]interface{}
|
||||
json.Unmarshal(w2.Body.Bytes(), &data)
|
||||
assert.Equal(s.T(), "User has already been taken", data["message"])
|
||||
assert.Equal(s.T(), []interface{}{"user_id"}, data["attributes"])
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestCreateAgentValidation() {
|
||||
|
||||
Reference in New Issue
Block a user