Skip to content

Commit 52d0bf0

Browse files
adityathebemoshloop
authored andcommitted
chore: fix test
1 parent 8d69598 commit 52d0bf0

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

models/connections_test.go

+10-15
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ func Test_Connection_AsGoGetterURL(t *testing.T) {
5353

5454
func Test_Connection_AsEnv(t *testing.T) {
5555
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
6060
}{
6161
{
6262
name: "AWS Connection",
@@ -72,9 +72,7 @@ func Test_Connection_AsEnv(t *testing.T) {
7272
"AWS_DEFAULT_PROFILE=awsprofile",
7373
"AWS_DEFAULT_REGION=us-east-1",
7474
},
75-
expectedFiles: map[string]string{
76-
"$HOME/.aws/credentials": "[default]\naws_access_key_id = awsuser\naws_secret_access_key = awssecret\nregion = us-east-1\n",
77-
},
75+
expectedFileContent: "[default]\naws_access_key_id = awsuser\naws_secret_access_key = awssecret\nregion = us-east-1\n",
7876
},
7977
{
8078
name: "GCP Connection",
@@ -83,10 +81,8 @@ func Test_Connection_AsEnv(t *testing.T) {
8381
Username: "gcpuser",
8482
Certificate: `{"account": "gcpuser"}`,
8583
},
86-
expectedEnv: []string{},
87-
expectedFiles: map[string]string{
88-
"$HOME/.config/gcloud/credentials": `{"account": "gcpuser"}`,
89-
},
84+
expectedEnv: []string{},
85+
expectedFileContent: `{"account": "gcpuser"}`,
9086
},
9187
}
9288

@@ -100,10 +96,9 @@ func Test_Connection_AsEnv(t *testing.T) {
10096
}
10197
}
10298

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())
107102
}
108103
}
109104
})

0 commit comments

Comments
 (0)