github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/registry/storage/driver/azure/azure_test.go (about) 1 package azure 2 3 import ( 4 "fmt" 5 "os" 6 "strings" 7 "testing" 8 9 storagedriver "github.com/docker/distribution/registry/storage/driver" 10 "github.com/docker/distribution/registry/storage/driver/testsuites" 11 . "gopkg.in/check.v1" 12 ) 13 14 const ( 15 envAccountName = "AZURE_STORAGE_ACCOUNT_NAME" 16 envAccountKey = "AZURE_STORAGE_ACCOUNT_KEY" 17 envContainer = "AZURE_STORAGE_CONTAINER" 18 envRealm = "AZURE_STORAGE_REALM" 19 ) 20 21 // Hook up gocheck into the "go test" runner. 22 func Test(t *testing.T) { TestingT(t) } 23 24 func init() { 25 var ( 26 accountName string 27 accountKey string 28 container string 29 realm string 30 ) 31 32 config := []struct { 33 env string 34 value *string 35 }{ 36 {envAccountName, &accountName}, 37 {envAccountKey, &accountKey}, 38 {envContainer, &container}, 39 {envRealm, &realm}, 40 } 41 42 missing := []string{} 43 for _, v := range config { 44 *v.value = os.Getenv(v.env) 45 if *v.value == "" { 46 missing = append(missing, v.env) 47 } 48 } 49 50 azureDriverConstructor := func() (storagedriver.StorageDriver, error) { 51 return New(accountName, accountKey, container, realm) 52 } 53 54 // Skip Azure storage driver tests if environment variable parameters are not provided 55 skipCheck := func() string { 56 if len(missing) > 0 { 57 return fmt.Sprintf("Must set %s environment variables to run Azure tests", strings.Join(missing, ", ")) 58 } 59 return "" 60 } 61 62 testsuites.RegisterSuite(azureDriverConstructor, skipCheck) 63 }