Skip to content

Commit

Permalink
feat(redis): more tests for redis metadb implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Aaron <[email protected]>
  • Loading branch information
andaaron committed Jan 23, 2025
1 parent 48f76b8 commit 3004819
Show file tree
Hide file tree
Showing 4 changed files with 1,544 additions and 10 deletions.
33 changes: 31 additions & 2 deletions pkg/extensions/search/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"
"time"

"github.com/alicebob/miniredis/v2"
guuid "github.com/gofrs/uuid"
regTypes "github.com/google/go-containerregistry/pkg/v1/types"
notreg "github.com/notaryproject/notation-go/registry"
Expand Down Expand Up @@ -3905,14 +3906,28 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
So(len(results.Repos), ShouldEqual, 0)
})

Convey("test nested indexes", t, func() {
Convey("test nested indexes CVE scanning disabled", t, func() {
log := log.NewLogger("debug", "")
rootDir := t.TempDir()
port := GetFreePort()
baseURL := GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
conf.Storage.RootDirectory = rootDir

Convey("test with boltdb", func() {
conf.Storage.CacheDriver = nil
})

Convey("test with redis", func() {
miniRedis := miniredis.RunT(t)

conf.Storage.CacheDriver = map[string]interface{}{
"name": "redis",
"url": "redis://" + miniRedis.Addr(),
}
})

defaultVal := true
conf.Extensions = &extconf.ExtensionConfig{
Search: &extconf.SearchConfig{BaseConfig: extconf.BaseConfig{Enable: &defaultVal}},
Expand Down Expand Up @@ -4054,14 +4069,28 @@ func TestGlobalSearch(t *testing.T) { //nolint: gocyclo
}
})

Convey("test nested indexes", t, func() {
Convey("test nested indexes CVE scanning enabled", t, func() {
log := log.NewLogger("debug", "")
rootDir := t.TempDir()
port := GetFreePort()
baseURL := GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
conf.Storage.RootDirectory = rootDir

Convey("test with boltdb", func() {
conf.Storage.CacheDriver = nil
})

Convey("test with redis", func() {
miniRedis := miniredis.RunT(t)

conf.Storage.CacheDriver = map[string]interface{}{
"name": "redis",
"url": "redis://" + miniRedis.Addr(),
}
})

defaultVal := true

updateDuration, _ := time.ParseDuration("1h")
Expand Down
Loading

0 comments on commit 3004819

Please sign in to comment.