Skip to content

Commit

Permalink
Set test environment with t.Setenv
Browse files Browse the repository at this point in the history
  • Loading branch information
8W9aG committed Jan 23, 2025
1 parent 78e6236 commit d9562ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 2 additions & 10 deletions pkg/docker/fast_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ func TestFastPush(t *testing.T) {
defer server.Close()
url, err := url.Parse(server.URL)
require.NoError(t, err)
err = os.Setenv(schemeEnv, url.Scheme)
require.NoError(t, err)
err = os.Setenv(hostEnv, url.Host)
require.NoError(t, err)
t.Setenv(schemeEnv, url.Scheme)
t.Setenv(hostEnv, url.Host)

// Create directories
dir := t.TempDir()
Expand All @@ -41,10 +39,4 @@ func TestFastPush(t *testing.T) {
// Run fast push
err = FastPush("test", dir, command, context.Background())
require.NoError(t, err)

// Cleanup env
err = os.Unsetenv(schemeEnv)
require.NoError(t, err)
err = os.Unsetenv(hostEnv)
require.NoError(t, err)
}
12 changes: 2 additions & 10 deletions pkg/docker/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ func TestPush(t *testing.T) {
defer server.Close()
url, err := url.Parse(server.URL)
require.NoError(t, err)
err = os.Setenv(schemeEnv, url.Scheme)
require.NoError(t, err)
err = os.Setenv(hostEnv, url.Host)
require.NoError(t, err)
t.Setenv(schemeEnv, url.Scheme)
t.Setenv(hostEnv, url.Host)

// Create directories
dir := t.TempDir()
Expand All @@ -40,10 +38,4 @@ func TestPush(t *testing.T) {
// Run fast push
err = Push("test", true, dir, command)
require.NoError(t, err)

// Cleanup env
err = os.Unsetenv(schemeEnv)
require.NoError(t, err)
err = os.Unsetenv(hostEnv)
require.NoError(t, err)
}

0 comments on commit d9562ec

Please sign in to comment.