@@ -53,10 +53,10 @@ func Test_Connection_AsGoGetterURL(t *testing.T) {
53
53
54
54
func Test_Connection_AsEnv (t * testing.T ) {
55
55
testCases := []struct {
56
- name string
57
- connection Connection
58
- expectedEnv []string
59
- expectedFiles map [ string ] string
56
+ name string
57
+ connection Connection
58
+ expectedEnv []string
59
+ expectedFileContent string
60
60
}{
61
61
{
62
62
name : "AWS Connection" ,
@@ -72,9 +72,7 @@ func Test_Connection_AsEnv(t *testing.T) {
72
72
"AWS_DEFAULT_PROFILE=awsprofile" ,
73
73
"AWS_DEFAULT_REGION=us-east-1" ,
74
74
},
75
- expectedFiles : map [string ]string {
76
- "$HOME/.aws/credentials" : "[default]\n aws_access_key_id = awsuser\n aws_secret_access_key = awssecret\n region = us-east-1\n " ,
77
- },
75
+ expectedFileContent : "[default]\n aws_access_key_id = awsuser\n aws_secret_access_key = awssecret\n region = us-east-1\n " ,
78
76
},
79
77
{
80
78
name : "GCP Connection" ,
@@ -83,10 +81,8 @@ func Test_Connection_AsEnv(t *testing.T) {
83
81
Username : "gcpuser" ,
84
82
Certificate : `{"account": "gcpuser"}` ,
85
83
},
86
- expectedEnv : []string {},
87
- expectedFiles : map [string ]string {
88
- "$HOME/.config/gcloud/credentials" : `{"account": "gcpuser"}` ,
89
- },
84
+ expectedEnv : []string {},
85
+ expectedFileContent : `{"account": "gcpuser"}` ,
90
86
},
91
87
}
92
88
@@ -100,10 +96,9 @@ func Test_Connection_AsEnv(t *testing.T) {
100
96
}
101
97
}
102
98
103
- for path , expected := range tc .expectedFiles {
104
- got := envPrep .Files [path ]
105
- if got .String () != expected {
106
- t .Errorf ("Expected file content: %s, but got: %s" , expected , got .String ())
99
+ for _ , content := range envPrep .Files {
100
+ if content .String () != tc .expectedFileContent {
101
+ t .Errorf ("Expected file content: %s, but got: %s" , tc .expectedFileContent , content .String ())
107
102
}
108
103
}
109
104
})
0 commit comments