Switching sort method
This commit is contained in:
parent
8d98237a15
commit
2d5d1890d4
|
@ -8,7 +8,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
mostRecentSort = "created_at:desc"
|
||||
mostRecentSortDir = "desc"
|
||||
mostRecentSortKey = "created_at"
|
||||
)
|
||||
|
||||
var validFields = map[string]string{
|
||||
|
@ -99,7 +100,8 @@ func buildImageFilters(input map[string]interface{}, listOpts *images.ListOpts)
|
|||
func applyMostRecent(listOpts *images.ListOpts) {
|
||||
// Sort isn't supported through our API so there should be no existing values.
|
||||
// Overwriting .Sort is okay.
|
||||
listOpts.Sort = mostRecentSort
|
||||
listOpts.SortKey = mostRecentSortKey
|
||||
listOpts.SortDir = mostRecentSortDir
|
||||
listOpts.Limit = 1
|
||||
|
||||
return
|
||||
|
|
|
@ -78,7 +78,7 @@ func TestApplyMostRecent(t *testing.T) {
|
|||
|
||||
applyMostRecent(&testSortOpts)
|
||||
|
||||
if testSortOpts.Sort != "created_at:desc" {
|
||||
if testSortOpts.SortKey != "created_at" || testSortOpts.SortDir != "desc" {
|
||||
t.Errorf("Error applying most recent filter: sort")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue