feat(agents): align delete scope
This commit is contained in:
@@ -322,6 +322,27 @@ func (s *AgentHandlerTestSuite) TestDeleteAgent() {
|
||||
assert.Equal(s.T(), http.StatusNotFound, w3.Code)
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestDeleteAgentNotInAccountReturnsNotFound() {
|
||||
otherAccount := &model.Account{Name: "Other Account", Locale: "en", Active: true}
|
||||
s.Require().NoError(s.db.Create(otherAccount).Error)
|
||||
otherUser := &model.User{Name: "Other Agent", Email: "other-agent@test.com", Provider: "email", Active: true}
|
||||
s.Require().NoError(s.db.Create(otherUser).Error)
|
||||
s.Require().NoError(s.db.Create(&model.AccountUser{AccountID: otherAccount.ID, UserID: otherUser.ID, Role: "agent", Availability: "offline", AutoOffline: true}).Error)
|
||||
|
||||
w, c := s.makeRequest("DELETE", fmt.Sprintf("/api/v1/accounts/%d/agents/%d", s.account.ID, otherUser.ID), nil, s.account.ID, s.user.ID)
|
||||
s.handler.Delete(c)
|
||||
|
||||
assert.Equal(s.T(), http.StatusNotFound, w.Code, w.Body.String())
|
||||
|
||||
var userCount int64
|
||||
s.Require().NoError(s.db.Model(&model.User{}).Where("id = ?", otherUser.ID).Count(&userCount).Error)
|
||||
assert.Equal(s.T(), int64(1), userCount)
|
||||
|
||||
var membershipCount int64
|
||||
s.Require().NoError(s.db.Model(&model.AccountUser{}).Where("account_id = ? AND user_id = ?", otherAccount.ID, otherUser.ID).Count(&membershipCount).Error)
|
||||
assert.Equal(s.T(), int64(1), membershipCount)
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestBulkCreate() {
|
||||
req := service.BulkCreateAgentRequest{
|
||||
Emails: []string{"bulk1@test.com", "bulk2@test.com", "bulk3@test.com"},
|
||||
|
||||
Reference in New Issue
Block a user