mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 11:37:56 +08:00
da426850e7
* chore: Update golangci-lint Signed-off-by: Lars Francke <git@lars-francke.de> * chore: fix all golangci-lint issues - Remove deprecated `// +build` tags - Fix godoclint, modernize, wsl_v5, govet, lll, gci, noctx issues - Update linter configuration - Modernize code to use Go 1.22+ features (for range N, slices.Contains, etc.) - Update make check lint the privileged tests Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> --------- Signed-off-by: Lars Francke <git@lars-francke.de> Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com> Co-authored-by: Lars Francke <git@lars-francke.de>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
//go:build search
|
|
|
|
package client_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
. "zotregistry.dev/zot/v2/pkg/cli/client"
|
|
gql_gen "zotregistry.dev/zot/v2/pkg/extensions/search/gql_generated"
|
|
)
|
|
|
|
func TestSortFlagsMapping(t *testing.T) {
|
|
// We do this to not import the whole gql_gen in the CLI
|
|
Convey("Make sure the sort-by values map correctly to the gql enum type", t, func() {
|
|
So(Flag2SortCriteria(SortByRelevance), ShouldResemble, string(gql_gen.SortCriteriaRelevance))
|
|
So(Flag2SortCriteria(SortByUpdateTime), ShouldResemble, string(gql_gen.SortCriteriaUpdateTime))
|
|
So(Flag2SortCriteria(SortByAlphabeticAsc), ShouldResemble, string(gql_gen.SortCriteriaAlphabeticAsc))
|
|
So(Flag2SortCriteria(SortByAlphabeticDsc), ShouldResemble, string(gql_gen.SortCriteriaAlphabeticDsc))
|
|
So(Flag2SortCriteria(SortBySeverity), ShouldResemble, string(gql_gen.SortCriteriaSeverity))
|
|
})
|
|
}
|
|
|
|
func TestSortFlags(t *testing.T) {
|
|
Convey("Flags", t, func() {
|
|
cveSortFlag := CVEListSortFlag("")
|
|
err := cveSortFlag.Set("bad-flag")
|
|
So(err, ShouldNotBeNil)
|
|
|
|
imageListSortFlag := ImageListSortFlag("")
|
|
err = imageListSortFlag.Set("bad-flag")
|
|
So(err, ShouldNotBeNil)
|
|
|
|
imageSearchSortFlag := ImageSearchSortFlag("")
|
|
err = imageSearchSortFlag.Set("bad-flag")
|
|
So(err, ShouldNotBeNil)
|
|
|
|
repoListSearchFlag := RepoListSortFlag("")
|
|
err = repoListSearchFlag.Set("bad-flag")
|
|
So(err, ShouldNotBeNil)
|
|
})
|
|
|
|
Convey("Flag2SortCriteria", t, func() {
|
|
So(Flag2SortCriteria("bad-flag"), ShouldResemble, "BAD_SORT_CRITERIA")
|
|
})
|
|
}
|