Skip to content

Commit

Permalink
unit test: Restore the original env variable using defer
Browse files Browse the repository at this point in the history
Fixes: 840b570 ("Add a function to check if the CLI is in Helm mode")

Signed-off-by: Michi Mutsuzaki <[email protected]>
  • Loading branch information
michi-covalent committed May 10, 2023
1 parent 148f953 commit 1d110cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,13 @@ func TestBuildImagePath(t *testing.T) {

func TestIsInHelmMode(t *testing.T) {
orig := os.Getenv(CLIModeVariableName)
defer func() {
assert.NoError(t, os.Setenv(CLIModeVariableName, orig))
}()
assert.NoError(t, os.Setenv(CLIModeVariableName, "helm"))
assert.True(t, IsInHelmMode())
assert.NoError(t, os.Setenv(CLIModeVariableName, "classic"))
assert.False(t, IsInHelmMode())
assert.NoError(t, os.Setenv(CLIModeVariableName, "random"))
assert.False(t, IsInHelmMode())
assert.NoError(t, os.Setenv(CLIModeVariableName, orig))
}

0 comments on commit 1d110cc

Please sign in to comment.