cli/command: remove deprecated io/ioutil and use t.TempDir()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-02-25 14:35:28 +01:00
parent cca73bff41
commit 3f7e7bf9d2
4 changed files with 20 additions and 37 deletions

View File

@ -1,7 +1,6 @@
package command
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -37,15 +36,13 @@ func TestStringSliceReplaceAt(t *testing.T) {
}
func TestValidateOutputPath(t *testing.T) {
basedir, err := ioutil.TempDir("", "TestValidateOutputPath")
assert.NilError(t, err)
defer os.RemoveAll(basedir)
basedir := t.TempDir()
dir := filepath.Join(basedir, "dir")
notexist := filepath.Join(basedir, "notexist")
err = os.MkdirAll(dir, 0755)
err := os.MkdirAll(dir, 0755)
assert.NilError(t, err)
file := filepath.Join(dir, "file")
err = ioutil.WriteFile(file, []byte("hi"), 0644)
err = os.WriteFile(file, []byte("hi"), 0644)
assert.NilError(t, err)
var testcases = []struct {
path string