Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using - instead of _ for Azure blob storage container name in tests #1498

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ steps:
from_secret: GCS_SERVICE_ACCOUNT
GCS_PROJECT_ID:
from_secret: GOOGLE_CLOUD_PROJECT
ATHENS_AZURE_ACCOUNT_NAME:
from_secret: ATHENS_AZURE_ACCOUNT_NAME
ATHENS_ACCOUNT_NAME:
from_secret: AZURE_ACCOUNT_NAME
ATHENS_AZURE_ACCOUNT_KEY:
from_secret: ATHENS_AZURE_ACCOUNT_KEY
when:
Expand Down
13 changes: 8 additions & 5 deletions pkg/stash/with_azureblob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
// is done synchronously so that only the first module gets saved.
func TestWithAzureBlob(t *testing.T) {
containerName := randomContainerName(os.Getenv("DRONE_PULL_REQUEST"))
cfg := getAzureTestConfig(containerName)

cfg := getAzureTestConfig(t, containerName)
if cfg == nil {
t.SkipNow()
}
Expand Down Expand Up @@ -84,14 +85,16 @@ func (ms *mockAzureBlobStasher) Stash(ctx context.Context, mod, ver string) (str
return "", fmt.Errorf("second time error")
}

func getAzureTestConfig(containerName string) *config.AzureBlobConfig {
func getAzureTestConfig(t *testing.T, containerName string) *config.AzureBlobConfig {
key := os.Getenv("ATHENS_AZURE_ACCOUNT_KEY")
if key == "" {
t.Log("ATHENS_AZURE_ACCOUNT_KEY not provided.")
return nil
}
name := os.Getenv("ATHENS_AZURE_ACCOUNT_NAME")
name := os.Getenv("AZURE_ACCOUNT_NAME")
if name == "" {
return nil
t.Log("AZURE_ACCOUNT_NAME not provided, falling back to 'athens'.")
name = "athens"
}
return &config.AzureBlobConfig{
AccountName: name,
Expand All @@ -105,7 +108,7 @@ func randomContainerName(prefix string) string {
// see https://github.com/technosophos/moniker for more details
namer := moniker.New()
if prefix != "" {
return fmt.Sprintf("%s_%s", prefix, namer.NameSep(""))
return fmt.Sprintf("%s-%s", prefix, namer.NameSep(""))
}
return namer.NameSep("")
}