From 4eac4fbf4cca256082d6baca260f572d84305f42 Mon Sep 17 00:00:00 2001 From: Caleb Brose <5447118+cmbrose@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:48:23 -0500 Subject: [PATCH] Make a new dir per test to work around windows failures --- pkg/cmd/codespace/ssh_test.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pkg/cmd/codespace/ssh_test.go b/pkg/cmd/codespace/ssh_test.go index 3f2a8a23b..adad394d3 100644 --- a/pkg/cmd/codespace/ssh_test.go +++ b/pkg/cmd/codespace/ssh_test.go @@ -26,12 +26,6 @@ func TestPendingOperationDisallowsSSH(t *testing.T) { } func TestAutomaticSSHKeyPairs(t *testing.T) { - dir := t.TempDir() - - sshContext := ssh.Context{ - ConfigDir: dir, - } - tests := []struct { // These files exist when calling setupAutomaticSSHKeys existingFiles []string @@ -71,15 +65,14 @@ func TestAutomaticSSHKeyPairs(t *testing.T) { } for _, tt := range tests { - err := os.RemoveAll(dir) - if err != nil { - t.Errorf("Failed to clean test directory: %v", err) - } - err = os.MkdirAll(dir, 0711) - if err != nil { - t.Errorf("Failed to set up test directory: %v", err) + dir := t.TempDir() + + sshContext := ssh.Context{ + ConfigDir: dir, } + defer os.RemoveAll(dir) + for _, file := range tt.existingFiles { if _, err := os.Create(filepath.Join(dir, file)); err != nil { t.Errorf("Failed to setup test files: %v", err)