Skip to content

Commit 83278b5

Browse files
committed
Update tag list conformance test to verify sort order
> If the list is not empty, the tags MUST be in lexical order (i.e. case-insensitive alphanumeric order). Signed-off-by: Tianon Gravi <[email protected]>
1 parent 583e014 commit 83278b5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

conformance/03_discovery_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/http"
77
"os"
8+
"sort"
89
"strconv"
910
"strings"
1011

@@ -253,14 +254,18 @@ var test03ContentDiscovery = func() {
253254
})
254255

255256
g.Context("Test content discovery endpoints (listing tags)", func() {
256-
g.Specify("GET request to list tags should yield 200 response", func() {
257+
g.Specify("GET request to list tags should yield 200 response and be in sorted order", func() {
257258
SkipIfDisabled(contentDiscovery)
258259
req := client.NewRequest(reggie.GET, "/v2/<name>/tags/list")
259260
resp, err := client.Do(req)
260261
Expect(err).To(BeNil())
261262
Expect(resp.StatusCode()).To(Equal(http.StatusOK))
262263
tagList = getTagList(resp)
263264
numTags = len(tagList)
265+
// If the list is not empty, the tags MUST be in lexical order (i.e. case-insensitive alphanumeric order).
266+
sortedTagList := append([]string{}, tagList...)
267+
sort.Slice(sortedTagList, func(i, j int) bool { return strings.ToLower(sortedTagList[i]) < strings.ToLower(sortedTagList[j]) })
268+
Expect(tagList).To(Equal(sortedTagList))
264269
})
265270

266271
g.Specify("GET number of tags should be limitable by `n` query parameter", func() {

0 commit comments

Comments
 (0)