mirror of
https://github.com/helm/helm.git
synced 2026-08-05 07:30:46 +00:00
test: replace ensure.TempDir with t.TempDir
This commit replaces `ensure.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ensure.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -29,14 +29,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"helm.sh/helm/v3/internal/test/ensure"
|
||||
"helm.sh/helm/v3/pkg/chart"
|
||||
"helm.sh/helm/v3/pkg/chart/loader"
|
||||
)
|
||||
|
||||
func TestSave(t *testing.T) {
|
||||
tmp := ensure.TempDir(t)
|
||||
defer os.RemoveAll(tmp)
|
||||
tmp := t.TempDir()
|
||||
|
||||
for _, dest := range []string{tmp, filepath.Join(tmp, "newdir")} {
|
||||
t.Run("outDir="+dest, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user