Skip to content

Commit 172d5c8

Browse files
Copilotpelikhan
andauthored
fix: use os.Unsetenv for GH_HOST unset test case
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 7f8bab0 commit 172d5c8

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/workflow/action_resolver_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package workflow
44

55
import (
66
"context"
7+
"os"
78
"slices"
89
"strings"
910
"testing"
@@ -286,7 +287,12 @@ func TestResolveFromGitHubForcesGitHubComHost(t *testing.T) {
286287
if tt.ghHost != "" {
287288
t.Setenv("GH_HOST", tt.ghHost)
288289
} else {
289-
t.Setenv("GH_HOST", "")
290+
// Truly unset GH_HOST (t.Setenv("GH_HOST", "") sets to empty string,
291+
// which is not the same as unset; use os.Unsetenv with cleanup instead).
292+
if err := os.Unsetenv("GH_HOST"); err != nil {
293+
t.Fatalf("failed to unset GH_HOST: %v", err)
294+
}
295+
t.Cleanup(func() { os.Unsetenv("GH_HOST") }) //nolint:errcheck
290296
}
291297

292298
cmd := ExecGHContext(context.Background(), "api", "/repos/actions/checkout/git/ref/tags/v4", "--jq", "[.object.sha, .object.type] | @tsv")

0 commit comments

Comments
 (0)