0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/cli/gql_queries_test.go
LaurentiuNiculae 112fbec5b6
refactor(cli): added equivalent subcommands for each flag combination under every command (#1674)
- image command is now deprecated in favor of 'images'
- cve command is now deprecated in favor of 'cves'

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
2023-08-30 20:12:24 +03:00

93 lines
2.2 KiB
Go

//go:build search
// +build search
package cli //nolint:testpackage
import (
"io"
"testing"
. "github.com/smartystreets/goconvey/convey"
"zotregistry.io/zot/pkg/api"
"zotregistry.io/zot/pkg/api/config"
extconf "zotregistry.io/zot/pkg/extensions/config"
"zotregistry.io/zot/pkg/test"
)
func TestGQLQueries(t *testing.T) {
port := test.GetFreePort()
baseURL := test.GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
dir := t.TempDir()
conf.Storage.RootDirectory = dir
defaultVal := true
conf.Extensions = &extconf.ExtensionConfig{
Search: &extconf.SearchConfig{
BaseConfig: extconf.BaseConfig{Enable: &defaultVal},
},
}
ctlr := api.NewController(conf)
cm := test.NewControllerManager(ctlr)
cm.StartAndWait(conf.HTTP.Port)
defer cm.StopServer()
searchConfig := searchConfig{
servURL: &baseURL,
user: ref(""),
verifyTLS: ref(false),
debug: ref(false),
resultWriter: io.Discard,
}
Convey("Make sure the current CLI used the right queries in case they change", t, func() {
Convey("ImageList", func() {
err := CheckExtEndPointQuery(searchConfig, ImageListQuery())
So(err, ShouldBeNil)
})
Convey("ImageListForDigest", func() {
err := CheckExtEndPointQuery(searchConfig, ImageListForDigestQuery())
So(err, ShouldBeNil)
})
Convey("BaseImageList", func() {
err := CheckExtEndPointQuery(searchConfig, BaseImageListQuery())
So(err, ShouldBeNil)
})
Convey("DerivedImageList", func() {
err := CheckExtEndPointQuery(searchConfig, DerivedImageListQuery())
So(err, ShouldBeNil)
})
Convey("CVEListForImage", func() {
err := CheckExtEndPointQuery(searchConfig, CVEListForImageQuery())
So(err, ShouldBeNil)
})
Convey("ImageListForCVE", func() {
err := CheckExtEndPointQuery(searchConfig, ImageListForCVEQuery())
So(err, ShouldBeNil)
})
Convey("ImageListWithCVEFixed", func() {
err := CheckExtEndPointQuery(searchConfig, ImageListWithCVEFixedQuery())
So(err, ShouldBeNil)
})
Convey("Referrers", func() {
err := CheckExtEndPointQuery(searchConfig, ReferrersQuery())
So(err, ShouldBeNil)
})
Convey("GlobalSearch", func() {
err := CheckExtEndPointQuery(searchConfig, GlobalSearchQuery())
So(err, ShouldBeNil)
})
})
}