Updated limit logic, removed limiter, updated test cases and sort field used
This commit is contained in:
parent
4147062802
commit
fc19cd8d28
@ -100,7 +100,6 @@ func applyMostRecent(listOpts *images.ListOpts) {
|
|||||||
// Sort isn't supported through our API so there should be no existing values.
|
// Sort isn't supported through our API so there should be no existing values.
|
||||||
// Overwriting ListOpts.Sort is okay.
|
// Overwriting ListOpts.Sort is okay.
|
||||||
listOpts.Sort = mostRecentSort
|
listOpts.Sort = mostRecentSort
|
||||||
listOpts.Limit = 1
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ func TestImageFilterOptionsDecode(t *testing.T) {
|
|||||||
err := mapstructure.Decode(input, &opts)
|
err := mapstructure.Decode(input, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Did not successfully generate ImageFilterOptions from %v.\nContains %v", input, opts)
|
t.Errorf("Did not successfully generate ImageFilterOptions from %v.\nContains %v", input, opts)
|
||||||
} else {
|
|
||||||
t.Log("Successfully generate ImageFilterOptions.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test case confirms that only allowed fields will be set to values
|
||||||
|
// The checked values are non-nil for their target type
|
||||||
func TestBuildImageFilter(t *testing.T) {
|
func TestBuildImageFilter(t *testing.T) {
|
||||||
testOpts := images.ListOpts{}
|
testOpts := images.ListOpts{}
|
||||||
|
|
||||||
@ -39,11 +39,7 @@ func TestBuildImageFilter(t *testing.T) {
|
|||||||
"tags": []string{"prod", "ready"},
|
"tags": []string{"prod", "ready"},
|
||||||
}
|
}
|
||||||
|
|
||||||
multiErr := buildImageFilters(filters, &testOpts)
|
buildImageFilters(filters, &testOpts)
|
||||||
|
|
||||||
if len(multiErr.Errors) > 0 {
|
|
||||||
t.Error(multiErr.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if testOpts.Limit != 0 {
|
if testOpts.Limit != 0 {
|
||||||
t.Errorf("Limit was parsed: %d", testOpts.Limit)
|
t.Errorf("Limit was parsed: %d", testOpts.Limit)
|
||||||
@ -78,7 +74,7 @@ func TestApplyMostRecent(t *testing.T) {
|
|||||||
|
|
||||||
applyMostRecent(&testSortOpts)
|
applyMostRecent(&testSortOpts)
|
||||||
|
|
||||||
if testSortOpts.SortKey != "created_at" || testSortOpts.SortDir != "desc" {
|
if testSortOpts.Sort != "created_at:desc" {
|
||||||
t.Errorf("Error applying most recent filter: sort")
|
t.Errorf("Error applying most recent filter: sort")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user