Skip to content

Commit

Permalink
code rabbit comments resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-wedensday committed Apr 5, 2024
1 parent 1cce3e9 commit 6f3eb37
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 208 deletions.
11 changes: 10 additions & 1 deletion internal/config/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ func TestFileName(t *testing.T) {
}
}

// keyValueArgs represents a key-value pair for environment variable setup
type keyValueArgs struct {
key string
value string
}

// args holds the setup for environment variables and expected key-value pairs for assertions.
type args struct {
setEnv []keyValueArgs
expectedKeyValues []keyValueArgs
Expand All @@ -174,7 +177,7 @@ func TestLoadEnv(t *testing.T) {
tests := getTestCases(username, host, dbname, password, port)
for _, tt := range tests {
setEnvironmentVariables(tt.args)

defer clearEnvironmentVariables(tt.args)
t.Run(tt.name, func(t *testing.T) {
testLoadEnv(t, tt)
})
Expand Down Expand Up @@ -348,3 +351,9 @@ func testLoadEnv(t *testing.T, tt struct {
}
}
}

func clearEnvironmentVariables(args args) {
for _, env := range args.setEnv {
os.Unsetenv(env.key)
}
}
Loading

0 comments on commit 6f3eb37

Please sign in to comment.