chore: Improve test cleanup (#3112)

This commit is contained in:
Mathias Fredriksson
2022-07-22 15:14:45 +03:00
committed by GitHub
parent 75ff579051
commit 7d07e670ca
4 changed files with 9 additions and 24 deletions
+2 -7
View File
@@ -206,7 +206,7 @@ func TestAgent(t *testing.T) {
t.Run("StartupScript", func(t *testing.T) {
t.Parallel()
tempPath := filepath.Join(os.TempDir(), "content.txt")
tempPath := filepath.Join(t.TempDir(), "content.txt")
content := "somethingnice"
setupAgent(t, agent.Metadata{
StartupScript: fmt.Sprintf("echo %s > %s", content, tempPath),
@@ -324,12 +324,7 @@ func TestAgent(t *testing.T) {
t.Skip("Unix socket forwarding isn't supported on Windows")
}
tmpDir, err := os.MkdirTemp("", "coderd_agent_test_")
require.NoError(t, err, "create temp dir for unix listener")
t.Cleanup(func() {
_ = os.RemoveAll(tmpDir)
})
tmpDir := t.TempDir()
l, err := net.Listen("unix", filepath.Join(tmpDir, "test.sock"))
require.NoError(t, err, "create UDP listener")
return l