mirror of
https://github.com/project-zot/zot.git
synced 2024-12-23 22:27:35 -05:00
d62c09e2cc
* feat(repodb): index logic + tests Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com> * feat(cli): printing indexes support using the rest api Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com> --------- Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package repodbfactory_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
bolt "zotregistry.io/zot/pkg/meta/repodb/boltdb-wrapper"
|
|
dynamoParams "zotregistry.io/zot/pkg/meta/repodb/dynamodb-wrapper/params"
|
|
"zotregistry.io/zot/pkg/meta/repodb/repodbfactory"
|
|
)
|
|
|
|
func TestCreateDynamo(t *testing.T) {
|
|
skipDynamo(t)
|
|
|
|
Convey("Create", t, func() {
|
|
dynamoDBDriverParams := dynamoParams.DBDriverParameters{
|
|
Endpoint: os.Getenv("DYNAMODBMOCK_ENDPOINT"),
|
|
RepoMetaTablename: "RepoMetadataTable",
|
|
ManifestDataTablename: "ManifestDataTable",
|
|
IndexDataTablename: "IndexDataTable",
|
|
VersionTablename: "Version",
|
|
Region: "us-east-2",
|
|
}
|
|
|
|
repoDB, err := repodbfactory.Create("dynamodb", dynamoDBDriverParams)
|
|
So(repoDB, ShouldNotBeNil)
|
|
So(err, ShouldBeNil)
|
|
})
|
|
|
|
Convey("Fails", t, func() {
|
|
So(func() { _, _ = repodbfactory.Create("dynamodb", bolt.DBParameters{RootDir: "root"}) }, ShouldPanic)
|
|
|
|
repoDB, err := repodbfactory.Create("random", bolt.DBParameters{RootDir: "root"})
|
|
So(repoDB, ShouldBeNil)
|
|
So(err, ShouldNotBeNil)
|
|
})
|
|
}
|
|
|
|
func TestCreateBoltDB(t *testing.T) {
|
|
Convey("Create", t, func() {
|
|
rootDir := t.TempDir()
|
|
|
|
repoDB, err := repodbfactory.Create("boltdb", bolt.DBParameters{
|
|
RootDir: rootDir,
|
|
})
|
|
So(repoDB, ShouldNotBeNil)
|
|
So(err, ShouldBeNil)
|
|
})
|
|
|
|
Convey("fails", t, func() {
|
|
So(func() { _, _ = repodbfactory.Create("boltdb", dynamoParams.DBDriverParameters{}) }, ShouldPanic)
|
|
})
|
|
}
|
|
|
|
func skipDynamo(t *testing.T) {
|
|
t.Helper()
|
|
|
|
if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" {
|
|
t.Skip("Skipping testing without AWS DynamoDB mock server")
|
|
}
|
|
}
|