feat(agents): align list ordering
This commit is contained in:
@@ -113,6 +113,30 @@ func (s *AgentHandlerTestSuite) TestListEmpty() {
|
||||
assert.Equal(s.T(), 0, len(data))
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestListOrdersByFullName() {
|
||||
agents := []service.CreateAgentRequest{
|
||||
{Email: "charlie@test.com", Name: "charlie", Role: "agent"},
|
||||
{Email: "alpha@test.com", Name: "Alpha", Role: "agent"},
|
||||
{Email: "bravo@test.com", Name: "bravo", Role: "agent"},
|
||||
}
|
||||
for _, req := range agents {
|
||||
w, c := s.makeRequest("POST", "/api/v1/accounts/1/agents", req, s.account.ID, s.user.ID)
|
||||
s.handler.Create(c)
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
}
|
||||
|
||||
w, c := s.makeRequest("GET", "/api/v1/accounts/1/agents", nil, s.account.ID, s.user.ID)
|
||||
s.handler.List(c)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
var data []map[string]interface{}
|
||||
json.Unmarshal(w.Body.Bytes(), &data)
|
||||
s.Require().Len(data, 3)
|
||||
assert.Equal(s.T(), "Alpha", data[0]["name"])
|
||||
assert.Equal(s.T(), "bravo", data[1]["name"])
|
||||
assert.Equal(s.T(), "charlie", data[2]["name"])
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestCreateAgent() {
|
||||
customRoleID := uint(7)
|
||||
req := service.CreateAgentRequest{
|
||||
|
||||
Reference in New Issue
Block a user