test: use T.TempDir
to create temporary test directory
The directory created by `T.TempDir` is automatically removed when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -21,8 +21,6 @@ package cio
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -65,11 +63,7 @@ func TestOpenFifosWithTerminal(t *testing.T) {
|
||||
var ctx, cancel = context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
ioFifoDir, err := os.MkdirTemp("", fmt.Sprintf("cio-%s", t.Name()))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error during creating temp dir: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(ioFifoDir)
|
||||
ioFifoDir := t.TempDir()
|
||||
|
||||
cfg := Config{
|
||||
Stdout: filepath.Join(ioFifoDir, "test-stdout"),
|
||||
|
Reference in New Issue
Block a user