Skip to content

Commit

Permalink
Skip aws s3 upload test if AWS vars are undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
bzon committed May 24, 2018
1 parent 61ce62c commit 94b3b6f
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions s3/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ import (

func TestUploadFile(t *testing.T) {
if os.Getenv("GOTEST_AWS_BUCKET") == "" {
t.Fatal("GOTEST_AWS_BUCKET env variable is not set.")
fmt.Println("Skipping Test")
return
}
if os.Getenv("AWS_ACCESS_KEY") == "" {
t.Fatal("AWS_ACCESS_KEY env variable is not set.")
fmt.Println("Skipping Test")
return
}
if os.Getenv("AWS_SECRET_ACCESS_KEY") == "" {
t.Fatal("AWS_SECRET_ACCESS_KEY env variable is not set.")
fmt.Println("Skipping Test")
return
}
file, err := os.Create("samplefile.txt")
if err != nil {
Expand Down Expand Up @@ -70,26 +73,28 @@ func TestUploadAssets(t *testing.T) {
{"upload ios assets", "ios_test", "../parser/testdata/sample.ipa"},
{"upload android assets", "android_test", "../parser/testdata/sample.apk"},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
appInfo, err := ipapk.NewAppParser(tc.file)
if err != nil {
t.Fatal(err)
}
var app parser.MobileApp
app.UploadDate = time.Now().Format(time.RFC1123)
app.AppInfo = appInfo
app.File = tc.file
if err := app.GenerateAssets(); err != nil {
t.Fatal(err)
}
assets, err := UploadAssets(&app, os.Getenv("GOTEST_AWS_BUCKET"), tc.destDir)
if err != nil {
t.Fatal(err)
}
for _, v := range assets {
fmt.Println("s3 url:", v)
}
})
if os.Getenv("GOTEST_AWS_BUCKET") != "" {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
appInfo, err := ipapk.NewAppParser(tc.file)
if err != nil {
t.Fatal(err)
}
var app parser.MobileApp
app.UploadDate = time.Now().Format(time.RFC1123)
app.AppInfo = appInfo
app.File = tc.file
if err := app.GenerateAssets(); err != nil {
t.Fatal(err)
}
assets, err := UploadAssets(&app, os.Getenv("GOTEST_AWS_BUCKET"), tc.destDir)
if err != nil {
t.Fatal(err)
}
for _, v := range assets {
fmt.Println("s3 url:", v)
}
})
}
}
}

0 comments on commit 94b3b6f

Please sign in to comment.