Switching sort method

This commit is contained in:
Tom Carrio 2018-07-20 08:29:53 -04:00
parent 8d98237a15
commit 2d5d1890d4
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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")
}
}