forked from TrueCloudLab/distribution
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 <james.hewitt@uk.ibm.com>
This commit is contained in:
parent
72dc264241
commit
46ff5f8528
1 changed files with 11 additions and 3 deletions
|
@ -22,6 +22,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var azureDriverConstructor func() (storagedriver.StorageDriver, error)
|
var azureDriverConstructor func() (storagedriver.StorageDriver, error)
|
||||||
|
var skipCheck func() string
|
||||||
|
|
||||||
// Hook up gocheck into the "go test" runner.
|
// Hook up gocheck into the "go test" runner.
|
||||||
func Test(t *testing.T) { check.TestingT(t) }
|
func Test(t *testing.T) { check.TestingT(t) }
|
||||||
|
@ -40,7 +41,7 @@ func init() {
|
||||||
value *string
|
value *string
|
||||||
missingOk bool
|
missingOk bool
|
||||||
}{
|
}{
|
||||||
{envAccountName, &accountName, true},
|
{envAccountName, &accountName, false},
|
||||||
{envAccountKey, &accountKey, true},
|
{envAccountKey, &accountKey, true},
|
||||||
{envContainer, &container, true},
|
{envContainer, &container, true},
|
||||||
{envRealm, &realm, true},
|
{envRealm, &realm, true},
|
||||||
|
@ -71,7 +72,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip Azure storage driver tests if environment variable parameters are not provided
|
// Skip Azure storage driver tests if environment variable parameters are not provided
|
||||||
skipCheck := func() string {
|
skipCheck = func() string {
|
||||||
if len(missing) > 0 {
|
if len(missing) > 0 {
|
||||||
return fmt.Sprintf("Must set %s environment variables to run Azure tests", strings.Join(missing, ", "))
|
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) {
|
func TestCommitAfterMove(t *testing.T) {
|
||||||
|
if skipCheck() != "" {
|
||||||
|
t.Skip(skipCheck())
|
||||||
|
}
|
||||||
|
|
||||||
driver, err := azureDriverConstructor()
|
driver, err := azureDriverConstructor()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error creating azure driver: %v", err)
|
t.Fatalf("unexpected error creating azure driver: %v", err)
|
||||||
|
@ -152,7 +157,7 @@ func TestParamParsing(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input := []map[string]interface{}{
|
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": "default"}},
|
||||||
{"accountname": "acc1", "container": "c1", "credentials": map[string]interface{}{"type": "client_secret", "clientid": "c1", "tenantid": "t1", "secret": "s1"}},
|
{"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",
|
Container: "c1", AccountName: "acc1", AccountKey: "k1",
|
||||||
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
||||||
|
CopyStatusPollMaxRetry: 1, CopyStatusPollDelay: "10ms",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Container: "c1", AccountName: "acc1", Credentials: Credentials{Type: "default"},
|
Container: "c1", AccountName: "acc1", Credentials: Credentials{Type: "default"},
|
||||||
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
||||||
|
CopyStatusPollMaxRetry: 5, CopyStatusPollDelay: "100ms",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Container: "c1", AccountName: "acc1",
|
Container: "c1", AccountName: "acc1",
|
||||||
Credentials: Credentials{Type: "client_secret", ClientID: "c1", TenantID: "t1", Secret: "s1"},
|
Credentials: Credentials{Type: "client_secret", ClientID: "c1", TenantID: "t1", Secret: "s1"},
|
||||||
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
Realm: "core.windows.net", ServiceURL: "https://acc1.blob.core.windows.net",
|
||||||
|
CopyStatusPollMaxRetry: 5, CopyStatusPollDelay: "100ms",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, expected := range expecteds {
|
for i, expected := range expecteds {
|
||||||
|
|
Loading…
Reference in a new issue