From 46ff5f852811c2c37066770effd9b297a2a0d78c Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Tue, 15 Aug 2023 16:45:22 +0100 Subject: [PATCH] Fix Azure tests The Azure tests fail if there is no Azure configuration available, instead they should be skipped. Also, one of the Azure tests is wrong and doesn't match the code. Signed-off-by: James Hewitt --- registry/storage/driver/azure/azure_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/registry/storage/driver/azure/azure_test.go b/registry/storage/driver/azure/azure_test.go index 5fbd01ad..c0d4d2e6 100644 --- a/registry/storage/driver/azure/azure_test.go +++ b/registry/storage/driver/azure/azure_test.go @@ -22,6 +22,7 @@ const ( ) var azureDriverConstructor func() (storagedriver.StorageDriver, error) +var skipCheck func() string // Hook up gocheck into the "go test" runner. func Test(t *testing.T) { check.TestingT(t) } @@ -40,7 +41,7 @@ func init() { value *string missingOk bool }{ - {envAccountName, &accountName, true}, + {envAccountName, &accountName, false}, {envAccountKey, &accountKey, true}, {envContainer, &container, true}, {envRealm, &realm, true}, @@ -71,7 +72,7 @@ func init() { } // Skip Azure storage driver tests if environment variable parameters are not provided - skipCheck := func() string { + skipCheck = func() string { if len(missing) > 0 { return fmt.Sprintf("Must set %s environment variables to run Azure tests", strings.Join(missing, ", ")) } @@ -92,6 +93,10 @@ func randStringRunes(n int) string { } func TestCommitAfterMove(t *testing.T) { + if skipCheck() != "" { + t.Skip(skipCheck()) + } + driver, err := azureDriverConstructor() if err != nil { t.Fatalf("unexpected error creating azure driver: %v", err) @@ -152,7 +157,7 @@ func TestParamParsing(t *testing.T) { } } input := []map[string]interface{}{ - {"accountname": "acc1", "accountkey": "k1", "container": "c1"}, + {"accountname": "acc1", "accountkey": "k1", "container": "c1", "copy_status_poll_max_retry": 1, "copy_status_poll_delay": "10ms"}, {"accountname": "acc1", "container": "c1", "credentials": map[string]interface{}{"type": "default"}}, {"accountname": "acc1", "container": "c1", "credentials": map[string]interface{}{"type": "client_secret", "clientid": "c1", "tenantid": "t1", "secret": "s1"}}, } @@ -160,15 +165,18 @@ func TestParamParsing(t *testing.T) { { Container: "c1", AccountName: "acc1", AccountKey: "k1", Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net", + CopyStatusPollMaxRetry: 1, CopyStatusPollDelay: "10ms", }, { Container: "c1", AccountName: "acc1", Credentials: Credentials{Type: "default"}, Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net", + CopyStatusPollMaxRetry: 5, CopyStatusPollDelay: "100ms", }, { Container: "c1", AccountName: "acc1", Credentials: Credentials{Type: "client_secret", ClientID: "c1", TenantID: "t1", Secret: "s1"}, Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net", + CopyStatusPollMaxRetry: 5, CopyStatusPollDelay: "100ms", }, } for i, expected := range expecteds {