-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathinternal_test.go
45 lines (40 loc) · 892 Bytes
/
internal_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package internal
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/aws/aws-sdk-go-v2/config"
)
var (
mockProfile string
mockAwsKey string
mockAwsSecret string
mockRegion string
)
func TestMain(m *testing.M) {
if os.Getenv("CIRCLECI") != "" {
os.Exit(0)
}
mockProfile = "default"
filename := filepath.Join(os.Getenv("HOME"), ".aws/credentials")
if _, err := os.Stat(filename); os.IsNotExist(err) {
os.Exit(0)
} else {
cfg, err := NewSharedConfig(context.Background(), mockProfile,
[]string{config.DefaultSharedConfigFilename()},
[]string{config.DefaultSharedCredentialsFilename()},
)
if err != nil {
os.Exit(0)
}
cred, err := cfg.Credentials.Retrieve(context.Background())
if err != nil {
panic(err)
}
mockAwsKey = cred.AccessKeyID
mockAwsSecret = cred.SecretAccessKey
mockRegion = cfg.Region
os.Exit(m.Run())
}
}