Add tests for tags list pagination

Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
This commit is contained in:
João Pereira
2021-05-22 15:15:49 +01:00
parent d80a63f1ea
commit 8ef268df25
3 changed files with 178 additions and 2 deletions

View File

@@ -128,7 +128,7 @@ func (ub *URLBuilder) BuildCatalogURL(values ...url.Values) (string, error) {
}
// BuildTagsURL constructs a url to list the tags in the named repository.
func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) {
func (ub *URLBuilder) BuildTagsURL(name reference.Named, values ...url.Values) (string, error) {
route := ub.cloneRoute(RouteNameTags)
tagsURL, err := route.URL("name", name.Name())
@@ -136,7 +136,7 @@ func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) {
return "", err
}
return tagsURL.String(), nil
return appendValuesURL(tagsURL, values...).String(), nil
}
// BuildManifestURL constructs a url for the manifest identified by name and

View File

@@ -34,6 +34,26 @@ func makeURLBuilderTestCases(urlBuilder *URLBuilder) []urlBuilderTestCase {
return urlBuilder.BuildTagsURL(fooBarRef)
},
},
{
description: "test tags url with n query parameter",
expectedPath: "/v2/foo/bar/tags/list?n=10",
expectedErr: nil,
build: func() (string, error) {
return urlBuilder.BuildTagsURL(fooBarRef, url.Values{
"n": []string{"10"},
})
},
},
{
description: "test tags url with last query parameter",
expectedPath: "/v2/foo/bar/tags/list?last=abc-def",
expectedErr: nil,
build: func() (string, error) {
return urlBuilder.BuildTagsURL(fooBarRef, url.Values{
"last": []string{"abc-def"},
})
},
},
{
description: "test manifest url tagged ref",
expectedPath: "/v2/foo/bar/manifests/tag",