mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
7b1e24c99e
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
93 lines
2.2 KiB
Go
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: "",
|
|
verifyTLS: false,
|
|
debug: 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)
|
|
})
|
|
})
|
|
}
|