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>
pull/10666/head
Eng Zer Jun 3 years ago
parent 12f1bc0acd
commit 2e3e22a003
No known key found for this signature in database
GPG Key ID: DAEBBD2E34C111E6

@ -22,7 +22,6 @@ package main
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -50,11 +49,7 @@ func checkPermsStderr() (string, error) {
} }
func TestCheckPerms(t *testing.T) { func TestCheckPerms(t *testing.T) {
tdir, err := ioutil.TempDir("", "helmtest") tdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
tfile := filepath.Join(tdir, "testconfig") tfile := filepath.Join(tdir, "testconfig")
fh, err := os.OpenFile(tfile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0440) fh, err := os.OpenFile(tfile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0440)
if err != nil { if err != nil {

@ -25,18 +25,14 @@ import (
) )
func TestAtomicWriteFile(t *testing.T) { func TestAtomicWriteFile(t *testing.T) {
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
testpath := filepath.Join(dir, "test") testpath := filepath.Join(dir, "test")
stringContent := "Test content" stringContent := "Test content"
reader := bytes.NewReader([]byte(stringContent)) reader := bytes.NewReader([]byte(stringContent))
mode := os.FileMode(0644) mode := os.FileMode(0644)
err = AtomicWriteFile(testpath, reader, mode) err := AtomicWriteFile(testpath, reader, mode)
if err != nil { if err != nil {
t.Errorf("AtomicWriteFile error: %s", err) t.Errorf("AtomicWriteFile error: %s", err)
} }

@ -46,13 +46,9 @@ var (
) )
func TestRenameWithFallback(t *testing.T) { func TestRenameWithFallback(t *testing.T) {
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
if err = RenameWithFallback(filepath.Join(dir, "does_not_exists"), filepath.Join(dir, "dst")); err == nil { if err := RenameWithFallback(filepath.Join(dir, "does_not_exists"), filepath.Join(dir, "dst")); err == nil {
t.Fatal("expected an error for non existing file, but got nil") t.Fatal("expected an error for non existing file, but got nil")
} }
@ -64,31 +60,27 @@ func TestRenameWithFallback(t *testing.T) {
srcf.Close() srcf.Close()
} }
if err = RenameWithFallback(srcpath, filepath.Join(dir, "dst")); err != nil { if err := RenameWithFallback(srcpath, filepath.Join(dir, "dst")); err != nil {
t.Fatal(err) t.Fatal(err)
} }
srcpath = filepath.Join(dir, "a") srcpath = filepath.Join(dir, "a")
if err = os.MkdirAll(srcpath, 0777); err != nil { if err := os.MkdirAll(srcpath, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
} }
dstpath := filepath.Join(dir, "b") dstpath := filepath.Join(dir, "b")
if err = os.MkdirAll(dstpath, 0777); err != nil { if err := os.MkdirAll(dstpath, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err = RenameWithFallback(srcpath, dstpath); err == nil { if err := RenameWithFallback(srcpath, dstpath); err == nil {
t.Fatal("expected an error if dst is an existing directory, but got nil") t.Fatal("expected an error if dst is an existing directory, but got nil")
} }
} }
func TestCopyDir(t *testing.T) { func TestCopyDir(t *testing.T) {
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcdir := filepath.Join(dir, "src") srcdir := filepath.Join(dir, "src")
if err := os.MkdirAll(srcdir, 0755); err != nil { if err := os.MkdirAll(srcdir, 0755); err != nil {
@ -108,7 +100,7 @@ func TestCopyDir(t *testing.T) {
for i, file := range files { for i, file := range files {
fn := filepath.Join(srcdir, file.path) fn := filepath.Join(srcdir, file.path)
dn := filepath.Dir(fn) dn := filepath.Dir(fn)
if err = os.MkdirAll(dn, 0755); err != nil { if err := os.MkdirAll(dn, 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -189,14 +181,10 @@ func TestCopyDirFail_SrcInaccessible(t *testing.T) {
}) })
defer cleanup() defer cleanup()
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dstdir = filepath.Join(dir, "dst") dstdir = filepath.Join(dir, "dst")
if err = CopyDir(srcdir, dstdir); err == nil { if err := CopyDir(srcdir, dstdir); err == nil {
t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir) t.Fatalf("expected error for CopyDir(%s, %s), got none", srcdir, dstdir)
} }
} }
@ -218,14 +206,10 @@ func TestCopyDirFail_DstInaccessible(t *testing.T) {
var srcdir, dstdir string var srcdir, dstdir string
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcdir = filepath.Join(dir, "src") srcdir = filepath.Join(dir, "src")
if err = os.MkdirAll(srcdir, 0755); err != nil { if err := os.MkdirAll(srcdir, 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -242,12 +226,9 @@ func TestCopyDirFail_DstInaccessible(t *testing.T) {
func TestCopyDirFail_SrcIsNotDir(t *testing.T) { func TestCopyDirFail_SrcIsNotDir(t *testing.T) {
var srcdir, dstdir string var srcdir, dstdir string
var err error
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcdir = filepath.Join(dir, "src") srcdir = filepath.Join(dir, "src")
if _, err = os.Create(srcdir); err != nil { if _, err = os.Create(srcdir); err != nil {
@ -268,12 +249,9 @@ func TestCopyDirFail_SrcIsNotDir(t *testing.T) {
func TestCopyDirFail_DstExists(t *testing.T) { func TestCopyDirFail_DstExists(t *testing.T) {
var srcdir, dstdir string var srcdir, dstdir string
var err error
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcdir = filepath.Join(dir, "src") srcdir = filepath.Join(dir, "src")
if err = os.MkdirAll(srcdir, 0755); err != nil { if err = os.MkdirAll(srcdir, 0755); err != nil {
@ -314,14 +292,10 @@ func TestCopyDirFailOpen(t *testing.T) {
var srcdir, dstdir string var srcdir, dstdir string
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcdir = filepath.Join(dir, "src") srcdir = filepath.Join(dir, "src")
if err = os.MkdirAll(srcdir, 0755); err != nil { if err := os.MkdirAll(srcdir, 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -345,11 +319,7 @@ func TestCopyDirFailOpen(t *testing.T) {
} }
func TestCopyFile(t *testing.T) { func TestCopyFile(t *testing.T) {
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcf, err := os.Create(filepath.Join(dir, "srcfile")) srcf, err := os.Create(filepath.Join(dir, "srcfile"))
if err != nil { if err != nil {
@ -405,13 +375,7 @@ func cleanUpDir(dir string) {
} }
func TestCopyFileSymlink(t *testing.T) { func TestCopyFileSymlink(t *testing.T) {
var tempdir, err = ioutil.TempDir("", "gotest") tempdir := t.TempDir()
if err != nil {
t.Fatalf("failed to create directory: %s", err)
}
defer cleanUpDir(tempdir)
testcases := map[string]string{ testcases := map[string]string{
filepath.Join("./testdata/symlinks/file-symlink"): filepath.Join(tempdir, "dst-file"), filepath.Join("./testdata/symlinks/file-symlink"): filepath.Join(tempdir, "dst-file"),
@ -477,11 +441,7 @@ func TestCopyFileFail(t *testing.T) {
t.Skip("Skipping for root user") t.Skip("Skipping for root user")
} }
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
srcf, err := os.Create(filepath.Join(dir, "srcfile")) srcf, err := os.Create(filepath.Join(dir, "srcfile"))
if err != nil { if err != nil {
@ -517,11 +477,7 @@ func TestCopyFileFail(t *testing.T) {
// files this function creates. It is the caller's responsibility to call // files this function creates. It is the caller's responsibility to call
// this function before the test is done running, whether there's an error or not. // this function before the test is done running, whether there's an error or not.
func setupInaccessibleDir(t *testing.T, op func(dir string) error) func() { func setupInaccessibleDir(t *testing.T, op func(dir string) error) func() {
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
return nil // keep compiler happy
}
subdir := filepath.Join(dir, "dir") subdir := filepath.Join(dir, "dir")
@ -529,9 +485,6 @@ func setupInaccessibleDir(t *testing.T, op func(dir string) error) func() {
if err := os.Chmod(subdir, 0777); err != nil { if err := os.Chmod(subdir, 0777); err != nil {
t.Error(err) t.Error(err)
} }
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
} }
if err := os.Mkdir(subdir, 0777); err != nil { if err := os.Mkdir(subdir, 0777); err != nil {
@ -617,14 +570,10 @@ func TestIsSymlink(t *testing.T) {
t.Skip("Skipping for root user") t.Skip("Skipping for root user")
} }
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
dirPath := filepath.Join(dir, "directory") dirPath := filepath.Join(dir, "directory")
if err = os.MkdirAll(dirPath, 0777); err != nil { if err := os.MkdirAll(dirPath, 0777); err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -18,7 +18,6 @@ package action
import ( import (
"flag" "flag"
"io/ioutil" "io/ioutil"
"os"
"testing" "testing"
fakeclientset "k8s.io/client-go/kubernetes/fake" fakeclientset "k8s.io/client-go/kubernetes/fake"
@ -38,13 +37,6 @@ var verbose = flag.Bool("test.log", false, "enable test logging")
func actionConfigFixture(t *testing.T) *Configuration { func actionConfigFixture(t *testing.T) *Configuration {
t.Helper() t.Helper()
tdir, err := ioutil.TempDir("", "helm-action-test")
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.RemoveAll(tdir) })
registryClient, err := registry.NewClient() registryClient, err := registry.NewClient()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

@ -18,7 +18,6 @@ package action
import ( import (
"bytes" "bytes"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -68,11 +67,7 @@ func TestList(t *testing.T) {
// chart names do not cause resolution problems. // chart names do not cause resolution problems.
func TestDependencyStatus_Dashes(t *testing.T) { func TestDependencyStatus_Dashes(t *testing.T) {
// Make a temp dir // Make a temp dir
dir, err := ioutil.TempDir("", "helmtest-") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
chartpath := filepath.Join(dir, "charts") chartpath := filepath.Join(dir, "charts")
if err := os.MkdirAll(chartpath, 0700); err != nil { if err := os.MkdirAll(chartpath, 0700); err != nil {
@ -81,7 +76,7 @@ func TestDependencyStatus_Dashes(t *testing.T) {
// Add some fake charts // Add some fake charts
first := buildChart(withName("first-chart")) first := buildChart(withName("first-chart"))
_, err = chartutil.Save(first, chartpath) _, err := chartutil.Save(first, chartpath)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -106,11 +101,7 @@ func TestDependencyStatus_Dashes(t *testing.T) {
func TestStatArchiveForStatus(t *testing.T) { func TestStatArchiveForStatus(t *testing.T) {
// Make a temp dir // Make a temp dir
dir, err := ioutil.TempDir("", "helmtest-") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
chartpath := filepath.Join(dir, "charts") chartpath := filepath.Join(dir, "charts")
if err := os.MkdirAll(chartpath, 0700); err != nil { if err := os.MkdirAll(chartpath, 0700); err != nil {

@ -20,7 +20,6 @@ import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
@ -552,15 +551,11 @@ func TestInstallReleaseOutputDir(t *testing.T) {
instAction := installAction(t) instAction := installAction(t)
vals := map[string]interface{}{} vals := map[string]interface{}{}
dir, err := ioutil.TempDir("", "output-dir") dir := t.TempDir()
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(dir)
instAction.OutputDir = dir instAction.OutputDir = dir
_, err = instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals) _, err := instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
if err != nil { if err != nil {
t.Fatalf("Failed install: %s", err) t.Fatalf("Failed install: %s", err)
} }
@ -588,11 +583,7 @@ func TestInstallOutputDirWithReleaseName(t *testing.T) {
instAction := installAction(t) instAction := installAction(t)
vals := map[string]interface{}{} vals := map[string]interface{}{}
dir, err := ioutil.TempDir("", "output-dir") dir := t.TempDir()
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(dir)
instAction.OutputDir = dir instAction.OutputDir = dir
instAction.UseReleaseName = true instAction.UseReleaseName = true
@ -600,7 +591,7 @@ func TestInstallOutputDirWithReleaseName(t *testing.T) {
newDir := filepath.Join(dir, instAction.ReleaseName) newDir := filepath.Join(dir, instAction.ReleaseName)
_, err = instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals) _, err := instAction.Run(buildChart(withSampleTemplates(), withMultipleManifestTemplate()), vals)
if err != nil { if err != nil {
t.Fatalf("Failed install: %s", err) t.Fatalf("Failed install: %s", err)
} }

@ -403,11 +403,7 @@ func TestLoadV2WithReqs(t *testing.T) {
} }
func TestLoadInvalidArchive(t *testing.T) { func TestLoadInvalidArchive(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "helm-test-") tmpdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)
writeTar := func(filename, internalPath string, body []byte) { writeTar := func(filename, internalPath string, body []byte) {
dest, err := os.Create(filename) dest, err := os.Create(filename)
@ -459,7 +455,7 @@ func TestLoadInvalidArchive(t *testing.T) {
} { } {
illegalChart := filepath.Join(tmpdir, tt.chartname) illegalChart := filepath.Join(tmpdir, tt.chartname)
writeTar(illegalChart, tt.internal, []byte("hello: world")) writeTar(illegalChart, tt.internal, []byte("hello: world"))
_, err = Load(illegalChart) _, err := Load(illegalChart)
if err == nil { if err == nil {
t.Fatal("expected error when unpacking illegal files") t.Fatal("expected error when unpacking illegal files")
} }
@ -471,7 +467,7 @@ func TestLoadInvalidArchive(t *testing.T) {
// Make sure that absolute path gets interpreted as relative // Make sure that absolute path gets interpreted as relative
illegalChart := filepath.Join(tmpdir, "abs-path.tgz") illegalChart := filepath.Join(tmpdir, "abs-path.tgz")
writeTar(illegalChart, "/Chart.yaml", []byte("hello: world")) writeTar(illegalChart, "/Chart.yaml", []byte("hello: world"))
_, err = Load(illegalChart) _, err := Load(illegalChart)
if err.Error() != "validation: chart.metadata.name is required" { if err.Error() != "validation: chart.metadata.name is required" {
t.Error(err) t.Error(err)
} }

@ -28,11 +28,7 @@ import (
) )
func TestCreate(t *testing.T) { func TestCreate(t *testing.T) {
tdir, err := ioutil.TempDir("", "helm-") tdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
c, err := Create("foo", tdir) c, err := Create("foo", tdir)
if err != nil { if err != nil {
@ -70,11 +66,7 @@ func TestCreate(t *testing.T) {
} }
func TestCreateFrom(t *testing.T) { func TestCreateFrom(t *testing.T) {
tdir, err := ioutil.TempDir("", "helm-") tdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
cf := &chart.Metadata{ cf := &chart.Metadata{
APIVersion: chart.APIVersionV1, APIVersion: chart.APIVersionV1,
@ -120,11 +112,7 @@ func TestCreateFrom(t *testing.T) {
// TestCreate_Overwrite is a regression test for making sure that files are overwritten. // TestCreate_Overwrite is a regression test for making sure that files are overwritten.
func TestCreate_Overwrite(t *testing.T) { func TestCreate_Overwrite(t *testing.T) {
tdir, err := ioutil.TempDir("", "helm-") tdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
var errlog bytes.Buffer var errlog bytes.Buffer

@ -17,18 +17,13 @@ limitations under the License.
package chartutil package chartutil
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
) )
func TestExpand(t *testing.T) { func TestExpand(t *testing.T) {
dest, err := ioutil.TempDir("", "helm-testing-") dest := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dest)
reader, err := os.Open("testdata/frobnitz-1.2.3.tgz") reader, err := os.Open("testdata/frobnitz-1.2.3.tgz")
if err != nil { if err != nil {
@ -81,11 +76,7 @@ func TestExpand(t *testing.T) {
} }
func TestExpandFile(t *testing.T) { func TestExpandFile(t *testing.T) {
dest, err := ioutil.TempDir("", "helm-testing-") dest := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dest)
if err := ExpandFile(dest, "testdata/frobnitz-1.2.3.tgz"); err != nil { if err := ExpandFile(dest, "testdata/frobnitz-1.2.3.tgz"); err != nil {
t.Fatal(err) t.Fatal(err)

@ -21,7 +21,6 @@ import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"io" "io"
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -129,11 +128,7 @@ func TestSavePreservesTimestamps(t *testing.T) {
// written timestamp for the files. // written timestamp for the files.
initialCreateTime := time.Now().Add(-1 * time.Second) initialCreateTime := time.Now().Add(-1 * time.Second)
tmp, err := ioutil.TempDir("", "helm-") tmp := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmp)
c := &chart.Chart{ c := &chart.Chart{
Metadata: &chart.Metadata{ Metadata: &chart.Metadata{
@ -203,11 +198,7 @@ func retrieveAllHeadersFromTar(path string) ([]*tar.Header, error) {
} }
func TestSaveDir(t *testing.T) { func TestSaveDir(t *testing.T) {
tmp, err := ioutil.TempDir("", "helm-") tmp := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmp)
c := &chart.Chart{ c := &chart.Chart{
Metadata: &chart.Metadata{ Metadata: &chart.Metadata{

@ -17,7 +17,6 @@ package downloader
import ( import (
"bytes" "bytes"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
@ -218,11 +217,7 @@ func TestGetRepoNames(t *testing.T) {
} }
func TestDownloadAll(t *testing.T) { func TestDownloadAll(t *testing.T) {
chartPath, err := ioutil.TempDir("", "test-downloadall") chartPath := t.TempDir()
if err != nil {
t.Fatalf("could not create tempdir: %v", err)
}
defer os.RemoveAll(chartPath)
m := &Manager{ m := &Manager{
Out: new(bytes.Buffer), Out: new(bytes.Buffer),
RepositoryConfig: repoConfig, RepositoryConfig: repoConfig,

@ -17,8 +17,6 @@ limitations under the License.
package lint package lint
import ( import (
"io/ioutil"
"os"
"strings" "strings"
"testing" "testing"
@ -120,11 +118,7 @@ func TestGoodChart(t *testing.T) {
// //
// See https://github.com/helm/helm/issues/7923 // See https://github.com/helm/helm/issues/7923
func TestHelmCreateChart(t *testing.T) { func TestHelmCreateChart(t *testing.T) {
dir, err := ioutil.TempDir("", "-helm-test") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
createdChart, err := chartutil.Create("testhelmcreatepasseslint", dir) createdChart, err := chartutil.Create("testhelmcreatepasseslint", dir)
if err != nil { if err != nil {

@ -21,7 +21,6 @@ import (
"compress/gzip" "compress/gzip"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -209,11 +208,7 @@ func TestHTTPInstallerUpdate(t *testing.T) {
func TestExtract(t *testing.T) { func TestExtract(t *testing.T) {
source := "https://repo.localdomain/plugins/fake-plugin-0.0.1.tar.gz" source := "https://repo.localdomain/plugins/fake-plugin-0.0.1.tar.gz"
tempDir, err := ioutil.TempDir("", "") tempDir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempDir)
// Set the umask to default open permissions so we can actually test // Set the umask to default open permissions so we can actually test
oldmask := syscall.Umask(0000) oldmask := syscall.Umask(0000)

@ -28,11 +28,7 @@ var _ Installer = new(LocalInstaller)
func TestLocalInstaller(t *testing.T) { func TestLocalInstaller(t *testing.T) {
// Make a temp dir // Make a temp dir
tdir, err := ioutil.TempDir("", "helm-installer-") tdir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tdir)
if err := ioutil.WriteFile(filepath.Join(tdir, "plugin.yaml"), []byte{}, 0644); err != nil { if err := ioutil.WriteFile(filepath.Join(tdir, "plugin.yaml"), []byte{}, 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -513,11 +513,7 @@ func TestIndexWrite(t *testing.T) {
if err := i.MustAdd(&chart.Metadata{APIVersion: "v2", Name: "clipper", Version: "0.1.0"}, "clipper-0.1.0.tgz", "http://example.com/charts", "sha256:1234567890"); err != nil { if err := i.MustAdd(&chart.Metadata{APIVersion: "v2", Name: "clipper", Version: "0.1.0"}, "clipper-0.1.0.tgz", "http://example.com/charts", "sha256:1234567890"); err != nil {
t.Fatalf("unexpected error: %s", err) t.Fatalf("unexpected error: %s", err)
} }
dir, err := ioutil.TempDir("", "helm-tmp") dir := t.TempDir()
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
testpath := filepath.Join(dir, "test") testpath := filepath.Join(dir, "test")
i.WriteFile(testpath, 0600) i.WriteFile(testpath, 0600)

Loading…
Cancel
Save