From 044ea85279565932a6b1313d73629eeb5c5ace56 Mon Sep 17 00:00:00 2001 From: Alexei Dodon Date: Thu, 5 Oct 2023 14:34:50 +0300 Subject: [PATCH] fix: running tests locally fails (#1879) Signed-off-by: Alexei Dodon --- pkg/api/controller_test.go | 35 ++++++------------- pkg/cli/client/client.go | 9 ----- pkg/cli/client/utils.go | 2 +- pkg/extensions/extension_image_trust_test.go | 11 ++---- pkg/extensions/imagetrust/image_trust_test.go | 11 ++---- pkg/extensions/sync/sync_test.go | 1 + pkg/meta/dynamodb/dynamodb_internal_test.go | 9 ++--- pkg/meta/dynamodb/dynamodb_test.go | 17 ++++----- pkg/meta/meta_test.go | 13 ++----- pkg/meta/parse_test.go | 11 ++---- pkg/meta/version/version_test.go | 10 +++--- pkg/storage/cache/dynamodb_test.go | 11 ++---- pkg/storage/s3/s3_test.go | 32 ++++++----------- pkg/storage/scrub_test.go | 3 +- pkg/storage/storage_test.go | 29 ++++++--------- pkg/test/skip/testskip.go | 22 ++++++++++++ 16 files changed, 88 insertions(+), 138 deletions(-) create mode 100644 pkg/test/skip/testskip.go diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index a0e06319..a7c0bb72 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -69,6 +69,7 @@ import ( "zotregistry.io/zot/pkg/test/mocks" ociutils "zotregistry.io/zot/pkg/test/oci-utils" "zotregistry.io/zot/pkg/test/signature" + tskip "zotregistry.io/zot/pkg/test/skip" ) const ( @@ -98,22 +99,6 @@ func getCredString(username, password string) string { return usernameAndHash } -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("S3MOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS S3 mock server") - } -} - -func skipDynamo(t *testing.T) { - t.Helper() - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS DynamoDB mock server") - } -} - func TestNew(t *testing.T) { Convey("Make a new controller", t, func() { conf := config.New() @@ -147,8 +132,8 @@ func TestCreateCacheDatabaseDriver(t *testing.T) { driver = storage.CreateCacheDatabaseDriver(conf.Storage.StorageConfig, log) So(driver, ShouldBeNil) }) - skipDynamo(t) - skipIt(t) + tskip.SkipDynamo(t) + tskip.SkipS3(t) Convey("Test CreateCacheDatabaseDriver dynamodb", t, func() { log := log.NewLogger("debug", "") dir := t.TempDir() @@ -166,9 +151,10 @@ func TestCreateCacheDatabaseDriver(t *testing.T) { "skipverify": false, } + endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT") conf.Storage.CacheDriver = map[string]interface{}{ "name": "dynamodb", - "endpoint": "http://localhost:4566", + "endpoint": endpoint, "region": "us-east-2", "cacheTablename": "BlobTable", "repoMetaTablename": "RepoMetadataTable", @@ -183,7 +169,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) { // negative test cases conf.Storage.CacheDriver = map[string]interface{}{ - "endpoint": "http://localhost:4566", + "endpoint": endpoint, "region": "us-east-2", "cacheTablename": "BlobTable", "repoMetaTablename": "RepoMetadataTable", @@ -197,7 +183,7 @@ func TestCreateCacheDatabaseDriver(t *testing.T) { conf.Storage.CacheDriver = map[string]interface{}{ "name": "dummy", - "endpoint": "http://localhost:4566", + "endpoint": endpoint, "region": "us-east-2", "cacheTablename": "BlobTable", "repoMetaTablename": "RepoMetadataTable", @@ -371,7 +357,8 @@ func TestAutoPortSelection(t *testing.T) { } func TestObjectStorageController(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) + tskip.SkipDynamo(t) bucket := "zot-storage-test" @@ -438,7 +425,7 @@ func TestObjectStorageController(t *testing.T) { conf.Storage.CacheDriver = map[string]interface{}{ "name": "dynamodb", - "endpoint": "http://localhost:4566", + "endpoint": os.Getenv("DYNAMODBMOCK_ENDPOINT"), "region": "us-east-2", "cachetablename": "test", "repometatablename": "RepoMetadataTable", @@ -493,7 +480,7 @@ func TestObjectStorageController(t *testing.T) { } func TestObjectStorageControllerSubPaths(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) bucket := "zot-storage-test" diff --git a/pkg/cli/client/client.go b/pkg/cli/client/client.go index da867ab2..d2dcf7a6 100644 --- a/pkg/cli/client/client.go +++ b/pkg/cli/client/client.go @@ -28,15 +28,6 @@ var ( httpClientLock sync.Mutex //nolint: gochecknoglobals ) -const ( - httpTimeout = 5 * time.Minute - certsPath = "/etc/containers/certs.d" - homeCertsDir = ".config/containers/certs.d" - clientCertFilename = "client.cert" - clientKeyFilename = "client.key" - caCertFilename = "ca.crt" -) - func makeGETRequest(ctx context.Context, url, username, password string, verifyTLS bool, debug bool, resultsPtr interface{}, configWriter io.Writer, ) (http.Header, error) { diff --git a/pkg/cli/client/utils.go b/pkg/cli/client/utils.go index 91f482a9..318e147e 100644 --- a/pkg/cli/client/utils.go +++ b/pkg/cli/client/utils.go @@ -118,7 +118,7 @@ func (spinner *spinnerState) stopSpinner() { } const ( - waitTimeout = httpTimeout + 5*time.Second + waitTimeout = 5 * time.Minute ) type stringResult struct { diff --git a/pkg/extensions/extension_image_trust_test.go b/pkg/extensions/extension_image_trust_test.go index 4b3ae2bf..654a9cb6 100644 --- a/pkg/extensions/extension_image_trust_test.go +++ b/pkg/extensions/extension_image_trust_test.go @@ -36,6 +36,7 @@ import ( test "zotregistry.io/zot/pkg/test/common" . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/signature" + tskip "zotregistry.io/zot/pkg/test/skip" ) type errReader int @@ -122,7 +123,7 @@ func TestSignatureUploadAndVerificationLocal(t *testing.T) { } func TestSignatureUploadAndVerificationAWS(t *testing.T) { - skipIt(t) + tskip.SkipDynamo(t) Convey("test with AWS", t, func() { uuid, err := guuid.NewV4() @@ -1000,11 +1001,3 @@ func RunSignatureUploadAndVerificationTests(t *testing.T, cacheDriverParams map[ So(resp.StatusCode(), ShouldEqual, http.StatusInternalServerError) }) } - -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS mock server") - } -} diff --git a/pkg/extensions/imagetrust/image_trust_test.go b/pkg/extensions/imagetrust/image_trust_test.go index 74858f5e..de204474 100644 --- a/pkg/extensions/imagetrust/image_trust_test.go +++ b/pkg/extensions/imagetrust/image_trust_test.go @@ -41,6 +41,7 @@ import ( . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/mocks" "zotregistry.io/zot/pkg/test/signature" + tskip "zotregistry.io/zot/pkg/test/skip" ) var ( @@ -658,7 +659,7 @@ func TestLocalTrustStore(t *testing.T) { } func TestAWSTrustStore(t *testing.T) { - skipIt(t) + tskip.SkipDynamo(t) trustpolicy := "trustpolicy" @@ -1336,11 +1337,3 @@ func RunVerificationTests(t *testing.T, dbDriverParams map[string]interface{}) { }) }) } - -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS mock server") - } -} diff --git a/pkg/extensions/sync/sync_test.go b/pkg/extensions/sync/sync_test.go index a3126ec7..20a57c01 100644 --- a/pkg/extensions/sync/sync_test.go +++ b/pkg/extensions/sync/sync_test.go @@ -2012,6 +2012,7 @@ func TestMandatoryAnnotations(t *testing.T) { logFile, err := os.CreateTemp("", "zot-log*.txt") So(err, ShouldBeNil) + defer os.Remove(logFile.Name()) destConfig.Log.Output = logFile.Name() diff --git a/pkg/meta/dynamodb/dynamodb_internal_test.go b/pkg/meta/dynamodb/dynamodb_internal_test.go index 560c5775..cad85a33 100644 --- a/pkg/meta/dynamodb/dynamodb_internal_test.go +++ b/pkg/meta/dynamodb/dynamodb_internal_test.go @@ -14,13 +14,14 @@ import ( "zotregistry.io/zot/pkg/log" //nolint:go-staticcheck "zotregistry.io/zot/pkg/meta/version" + tskip "zotregistry.io/zot/pkg/test/skip" ) func TestWrapperErrors(t *testing.T) { - const ( - endpoint = "http://localhost:4566" - region = "us-east-2" - ) + tskip.SkipDynamo(t) + + const region = "us-east-2" + endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT") uuid, err := guuid.NewV4() if err != nil { diff --git a/pkg/meta/dynamodb/dynamodb_test.go b/pkg/meta/dynamodb/dynamodb_test.go index 716dc039..4901d8ec 100644 --- a/pkg/meta/dynamodb/dynamodb_test.go +++ b/pkg/meta/dynamodb/dynamodb_test.go @@ -23,15 +23,16 @@ import ( mTypes "zotregistry.io/zot/pkg/meta/types" reqCtx "zotregistry.io/zot/pkg/requestcontext" . "zotregistry.io/zot/pkg/test/image-utils" + tskip "zotregistry.io/zot/pkg/test/skip" ) const badTablename = "bad tablename" func TestIterator(t *testing.T) { - const ( - endpoint = "http://localhost:4566" - region = "us-east-2" - ) + tskip.SkipDynamo(t) + + const region = "us-east-2" + endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT") uuid, err := guuid.NewV4() if err != nil { @@ -131,10 +132,10 @@ func TestIteratorErrors(t *testing.T) { } func TestWrapperErrors(t *testing.T) { - const ( - endpoint = "http://localhost:4566" - region = "us-east-2" - ) + tskip.SkipDynamo(t) + + const region = "us-east-2" + endpoint := os.Getenv("DYNAMODBMOCK_ENDPOINT") uuid, err := guuid.NewV4() if err != nil { diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go index 8697ff3c..7e9996df 100644 --- a/pkg/meta/meta_test.go +++ b/pkg/meta/meta_test.go @@ -35,6 +35,7 @@ import ( "zotregistry.io/zot/pkg/test/deprecated" . "zotregistry.io/zot/pkg/test/image-utils" signature "zotregistry.io/zot/pkg/test/signature" + tskip "zotregistry.io/zot/pkg/test/skip" ) const ( @@ -97,7 +98,7 @@ func TestBoltDB(t *testing.T) { } func TestDynamoDBWrapper(t *testing.T) { - skipIt(t) + tskip.SkipDynamo(t) uuid, err := guuid.NewV4() if err != nil { @@ -2688,7 +2689,7 @@ func generateTestImage() ([]byte, []byte, error) { } func TestCreateDynamo(t *testing.T) { - skipDynamo(t) + tskip.SkipDynamo(t) Convey("Create", t, func() { dynamoDBDriverParams := mdynamodb.DBDriverParameters{ @@ -2747,11 +2748,3 @@ func TestCreateBoltDB(t *testing.T) { So(func() { _, _ = meta.Create("boltdb", nil, mdynamodb.DBDriverParameters{}, log) }, ShouldPanic) }) } - -func skipDynamo(t *testing.T) { - t.Helper() - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS DynamoDB mock server") - } -} diff --git a/pkg/meta/parse_test.go b/pkg/meta/parse_test.go index fcccea0b..21ae0020 100644 --- a/pkg/meta/parse_test.go +++ b/pkg/meta/parse_test.go @@ -28,6 +28,7 @@ import ( . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/mocks" "zotregistry.io/zot/pkg/test/signature" + tskip "zotregistry.io/zot/pkg/test/skip" ) const repo = "repo" @@ -367,7 +368,7 @@ func TestParseStorageWithBoltDB(t *testing.T) { } func TestParseStorageDynamoWrapper(t *testing.T) { - skipIt(t) + tskip.SkipDynamo(t) Convey("Dynamodb", t, func() { rootDir := t.TempDir() @@ -596,14 +597,6 @@ func TestGetReferredInfo(t *testing.T) { }) } -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("S3MOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS S3 mock server") - } -} - func TestGetSignatureLayersInfo(t *testing.T) { Convey("wrong signature type", t, func() { layers, err := meta.GetSignatureLayersInfo("repo", "tag", "123", "wrong signature type", []byte{}, diff --git a/pkg/meta/version/version_test.go b/pkg/meta/version/version_test.go index 4a478779..e64dbbf7 100644 --- a/pkg/meta/version/version_test.go +++ b/pkg/meta/version/version_test.go @@ -18,6 +18,7 @@ import ( "zotregistry.io/zot/pkg/meta/boltdb" mdynamodb "zotregistry.io/zot/pkg/meta/dynamodb" "zotregistry.io/zot/pkg/meta/version" + tskip "zotregistry.io/zot/pkg/test/skip" ) var ErrTestError = errors.New("test error") @@ -113,15 +114,12 @@ func setBoltDBVersion(db *bbolt.DB, vers string) error { } func TestVersioningDynamoDB(t *testing.T) { - const ( - endpoint = "http://localhost:4566" - region = "us-east-2" - ) + tskip.SkipDynamo(t) Convey("Tests", t, func() { params := mdynamodb.DBDriverParameters{ - Endpoint: endpoint, - Region: region, + Endpoint: os.Getenv("DYNAMODBMOCK_ENDPOINT"), + Region: "us-east-2", RepoMetaTablename: "RepoMetadataTable", ManifestDataTablename: "ManifestDataTable", IndexDataTablename: "IndexDataTable", diff --git a/pkg/storage/cache/dynamodb_test.go b/pkg/storage/cache/dynamodb_test.go index 64a67f4d..bf961bcc 100644 --- a/pkg/storage/cache/dynamodb_test.go +++ b/pkg/storage/cache/dynamodb_test.go @@ -11,18 +11,11 @@ import ( "zotregistry.io/zot/pkg/log" "zotregistry.io/zot/pkg/storage" "zotregistry.io/zot/pkg/storage/cache" + tskip "zotregistry.io/zot/pkg/test/skip" ) -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS DynamoDB mock server") - } -} - func TestDynamoDB(t *testing.T) { - skipIt(t) + tskip.SkipDynamo(t) Convey("Test dynamoDB", t, func(c C) { log := log.NewLogger("debug", "") dir := t.TempDir() diff --git a/pkg/storage/s3/s3_test.go b/pkg/storage/s3/s3_test.go index a84d1039..a96486dd 100644 --- a/pkg/storage/s3/s3_test.go +++ b/pkg/storage/s3/s3_test.go @@ -40,6 +40,7 @@ import ( . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/inject" "zotregistry.io/zot/pkg/test/mocks" + tskip "zotregistry.io/zot/pkg/test/skip" ) //nolint:gochecknoglobals @@ -58,18 +59,6 @@ func cleanupStorage(store driver.StorageDriver, name string) { _ = store.Delete(context.Background(), name) } -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("S3MOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS S3 mock server") - } - - if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS DynamoDB mock server") - } -} - func createMockStorage(rootDir string, cacheDir string, dedupe bool, store driver.StorageDriver, ) storageTypes.ImageStore { log := log.Logger{Logger: zerolog.New(os.Stdout)} @@ -382,7 +371,7 @@ func (s *StorageDriverMock) Walk(ctx context.Context, path string, f driver.Walk } func TestStorageDriverStatFunction(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -462,7 +451,7 @@ func TestStorageDriverStatFunction(t *testing.T) { } func TestGetOrasAndOCIReferrers(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) repo := "zot-test" @@ -623,7 +612,7 @@ func TestGetOrasAndOCIReferrers(t *testing.T) { } func TestNegativeCasesObjectsStorage(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -1239,7 +1228,8 @@ func TestNegativeCasesObjectsStorage(t *testing.T) { } func TestS3Dedupe(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) + tskip.SkipDynamo(t) Convey("Dedupe", t, func(c C) { uuid, err := guuid.NewV4() if err != nil { @@ -1928,7 +1918,7 @@ func TestS3Dedupe(t *testing.T) { } func TestRebuildDedupeIndex(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) Convey("Push images with dedupe true", t, func() { uuid, err := guuid.NewV4() @@ -2260,7 +2250,7 @@ func TestRebuildDedupeIndex(t *testing.T) { } func TestRebuildDedupeMockStoreDriver(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -2783,7 +2773,7 @@ func TestRebuildDedupeMockStoreDriver(t *testing.T) { } func TestS3PullRange(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) Convey("Test against s3 image store", t, func() { uuid, err := guuid.NewV4() @@ -2959,7 +2949,7 @@ func TestS3PullRange(t *testing.T) { } func TestS3ManifestImageIndex(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) Convey("Test against s3 image store", t, func() { uuid, err := guuid.NewV4() @@ -3539,7 +3529,7 @@ func TestS3ManifestImageIndex(t *testing.T) { } func TestS3DedupeErr(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { diff --git a/pkg/storage/scrub_test.go b/pkg/storage/scrub_test.go index eef992ec..80d403af 100644 --- a/pkg/storage/scrub_test.go +++ b/pkg/storage/scrub_test.go @@ -29,6 +29,7 @@ import ( "zotregistry.io/zot/pkg/test/deprecated" . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/mocks" + tskip "zotregistry.io/zot/pkg/test/skip" ) const ( @@ -56,7 +57,7 @@ func TestLocalCheckAllBlobsIntegrity(t *testing.T) { } func TestS3CheckAllBlobsIntegrity(t *testing.T) { - skipIt(t) + tskip.SkipS3(t) Convey("test with S3 storage", t, func() { uuid, err := guuid.NewV4() diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index ce8fef9a..02399067 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -41,20 +41,13 @@ import ( storageTypes "zotregistry.io/zot/pkg/storage/types" . "zotregistry.io/zot/pkg/test/image-utils" "zotregistry.io/zot/pkg/test/mocks" + tskip "zotregistry.io/zot/pkg/test/skip" ) func cleanupStorage(store driver.StorageDriver, name string) { _ = store.Delete(context.Background(), name) } -func skipIt(t *testing.T) { - t.Helper() - - if os.Getenv("S3MOCK_ENDPOINT") == "" { - t.Skip("Skipping testing without AWS S3 mock server") - } -} - func createObjectsStore(rootDir string, cacheDir string) ( driver.StorageDriver, storageTypes.ImageStore, error, ) { @@ -120,7 +113,7 @@ func TestStorageAPIs(t *testing.T) { t.Run(testcase.testCaseName, func(t *testing.T) { var imgStore storageTypes.ImageStore if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -752,7 +745,7 @@ func TestMandatoryAnnotations(t *testing.T) { metrics := monitoring.NewMetricsServer(false, log) if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -876,7 +869,7 @@ func TestDeleteBlobsInUse(t *testing.T) { metrics := monitoring.NewMetricsServer(false, log) if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -1175,7 +1168,7 @@ func TestStorageHandler(t *testing.T) { var thirdRootDir string if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) var firstStorageDriver driver.StorageDriver var secondStorageDriver driver.StorageDriver var thirdStorageDriver driver.StorageDriver @@ -1263,7 +1256,7 @@ func TestGarbageCollectImageManifest(t *testing.T) { Convey("Garbage collect with default/long delay", func() { var imgStore storageTypes.ImageStore if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -1425,7 +1418,7 @@ func TestGarbageCollectImageManifest(t *testing.T) { gcDelay := 1 * time.Second if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -1736,7 +1729,7 @@ func TestGarbageCollectImageManifest(t *testing.T) { gcDelay := 3 * time.Second if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -1972,7 +1965,7 @@ func TestGarbageCollectImageIndex(t *testing.T) { Convey("Garbage collect with default/long delay", func() { var imgStore storageTypes.ImageStore if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -2102,7 +2095,7 @@ func TestGarbageCollectImageIndex(t *testing.T) { imageRetentionDelay := 2 * time.Second if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { @@ -2412,7 +2405,7 @@ func TestGarbageCollectChainedImageIndexes(t *testing.T) { imageRetentionDelay := 5 * time.Second if testcase.storageType == storageConstants.S3StorageDriverName { - skipIt(t) + tskip.SkipS3(t) uuid, err := guuid.NewV4() if err != nil { diff --git a/pkg/test/skip/testskip.go b/pkg/test/skip/testskip.go new file mode 100644 index 00000000..53794a8d --- /dev/null +++ b/pkg/test/skip/testskip.go @@ -0,0 +1,22 @@ +package skip + +import ( + "os" + "testing" +) + +func SkipS3(t *testing.T) { + t.Helper() + + if os.Getenv("S3MOCK_ENDPOINT") == "" { + t.Skip("Skipping testing without AWS S3 mock server") + } +} + +func SkipDynamo(t *testing.T) { + t.Helper() + + if os.Getenv("DYNAMODBMOCK_ENDPOINT") == "" { + t.Skip("Skipping testing without AWS DynamoDB mock server") + } +}