Skip to content

Commit

Permalink
fix(api): sort template bulk operations (#3892)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored and yesnault committed Jan 28, 2019
1 parent bc4b4fb commit a5bb1ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions engine/api/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"net/http"
"sort"
"strconv"
"time"

Expand Down Expand Up @@ -687,6 +688,9 @@ func (api *API) getTemplateBulkHandler() service.Handler {
if b == nil || (!u.Admin && u.ID != b.UserID) {
return sdk.NewErrorFrom(sdk.ErrNotFound, "No workflow template bulk found for id %d", id)
}
sort.Slice(b.Operations, func(i, j int) bool {
return b.Operations[i].Request.WorkflowName < b.Operations[j].Request.WorkflowName
})

return service.WriteJSON(w, b, http.StatusOK)
}
Expand Down
6 changes: 3 additions & 3 deletions tests/clictl_template_bulk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ testcases:
assertions:
- result.code ShouldEqual 0
- result.systemoutjson.operations.operations0.status ShouldEqual 2
- result.systemoutjson.operations.operations1.status ShouldEqual 2
- result.systemoutjson.operations.operations2.status ShouldEqual 3
- result.systemoutjson.operations.operations2.error ShouldEqual 'Unsupported when condition ok'
- result.systemoutjson.operations.operations1.status ShouldEqual 3
- result.systemoutjson.operations.operations1.error ShouldEqual 'Unsupported when condition ok'
- result.systemoutjson.operations.operations2.status ShouldEqual 2

0 comments on commit a5bb1ac

Please sign in to comment.