Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 18, 2023
1 parent 483bc3f commit fe151f7
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions models/connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func Test_Connection_AsGoGetterURL(t *testing.T) {

func Test_Connection_AsEnv(t *testing.T) {
testCases := []struct {
name string
connection Connection
expectedEnv []string
expectedFiles map[string]string
name string
connection Connection
expectedEnv []string
expectedFileContent string
}{
{
name: "AWS Connection",
Expand All @@ -72,9 +72,7 @@ func Test_Connection_AsEnv(t *testing.T) {
"AWS_DEFAULT_PROFILE=awsprofile",
"AWS_DEFAULT_REGION=us-east-1",
},
expectedFiles: map[string]string{
"$HOME/.aws/credentials": "[default]\naws_access_key_id = awsuser\naws_secret_access_key = awssecret\nregion = us-east-1\n",
},
expectedFileContent: "[default]\naws_access_key_id = awsuser\naws_secret_access_key = awssecret\nregion = us-east-1\n",
},
{
name: "GCP Connection",
Expand All @@ -83,10 +81,8 @@ func Test_Connection_AsEnv(t *testing.T) {
Username: "gcpuser",
Certificate: `{"account": "gcpuser"}`,
},
expectedEnv: []string{},
expectedFiles: map[string]string{
"$HOME/.config/gcloud/credentials": `{"account": "gcpuser"}`,
},
expectedEnv: []string{},
expectedFileContent: `{"account": "gcpuser"}`,
},
}

Expand All @@ -100,10 +96,9 @@ func Test_Connection_AsEnv(t *testing.T) {
}
}

for path, expected := range tc.expectedFiles {
got := envPrep.Files[path]
if got.String() != expected {
t.Errorf("Expected file content: %s, but got: %s", expected, got.String())
for _, content := range envPrep.Files {
if content.String() != tc.expectedFileContent {
t.Errorf("Expected file content: %s, but got: %s", tc.expectedFileContent, content.String())
}
}
})
Expand Down

0 comments on commit fe151f7

Please sign in to comment.