github.com/mponton/terratest@v0.44.0/modules/azure/region_test.go (about) 1 //go:build azure 2 // +build azure 3 4 // NOTE: We use build tags to differentiate azure testing because we currently do not have azure access setup for 5 // CircleCI. 6 7 package azure 8 9 import ( 10 "testing" 11 12 "github.com/stretchr/testify/assert" 13 ) 14 15 func TestGetRandomRegion(t *testing.T) { 16 t.Parallel() 17 18 randomRegion := GetRandomRegion(t, nil, nil, "") 19 assertLooksLikeRegionName(t, randomRegion) 20 } 21 22 func TestGetRandomRegionExcludesForbiddenRegions(t *testing.T) { 23 t.Parallel() 24 25 approvedRegions := []string{"canadacentral", "eastus", "eastus2", "westus", "westus2", "westeurope", "northeurope", "uksouth", "southeastasia", "eastasia", "japaneast", "australiacentral"} 26 forbiddenRegions := []string{"westus2", "japaneast"} 27 28 for i := 0; i < 48; i++ { 29 randomRegion := GetRandomRegion(t, approvedRegions, forbiddenRegions, "") 30 assert.NotContains(t, forbiddenRegions, randomRegion) 31 } 32 } 33 34 func TestGetAllAzureRegions(t *testing.T) { 35 t.Parallel() 36 37 regions := GetAllAzureRegions(t, "") 38 39 // The typical subscription had access to 30+ live regions as of 40 // July 2019: https://azure.microsoft.com/en-us/global-infrastructure/regions/ 41 assert.True(t, len(regions) >= 30, "Number of regions: %d", len(regions)) 42 for _, region := range regions { 43 assertLooksLikeRegionName(t, region) 44 } 45 } 46 47 func assertLooksLikeRegionName(t *testing.T, regionName string) { 48 assert.Regexp(t, "[a-z]", regionName) 49 }