mirror of
https://github.com/helm/helm.git
synced 2026-04-09 02:46:16 -04:00
Merge pull request #31021 from zachburg/test_temp_dir
Update tests in create_test.go and package_test.go to work in a temp directory
This commit is contained in:
commit
edd0dabe02
2 changed files with 6 additions and 10 deletions
|
|
@ -30,10 +30,9 @@ import (
|
|||
)
|
||||
|
||||
func TestCreateCmd(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
ensure.HelmHome(t)
|
||||
cname := "testchart"
|
||||
dir := t.TempDir()
|
||||
defer t.Chdir(dir)
|
||||
|
||||
// Run a create
|
||||
if _, _, err := executeActionCommand("create " + cname); err != nil {
|
||||
|
|
@ -61,12 +60,10 @@ func TestCreateCmd(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateStarterCmd(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
ensure.HelmHome(t)
|
||||
cname := "testchart"
|
||||
defer resetEnv()()
|
||||
os.MkdirAll(helmpath.CachePath(), 0o755)
|
||||
defer t.Chdir(helmpath.CachePath())
|
||||
|
||||
// Create a starter.
|
||||
starterchart := helmpath.DataPath("starters")
|
||||
os.MkdirAll(starterchart, 0o755)
|
||||
|
|
@ -125,6 +122,7 @@ func TestCreateStarterCmd(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateStarterAbsoluteCmd(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
defer resetEnv()()
|
||||
ensure.HelmHome(t)
|
||||
cname := "testchart"
|
||||
|
|
@ -142,9 +140,6 @@ func TestCreateStarterAbsoluteCmd(t *testing.T) {
|
|||
t.Fatalf("Could not write template: %s", err)
|
||||
}
|
||||
|
||||
os.MkdirAll(helmpath.CachePath(), 0o755)
|
||||
defer t.Chdir(helmpath.CachePath())
|
||||
|
||||
starterChartPath := filepath.Join(starterchart, "starterchart")
|
||||
|
||||
// Run a create
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"helm.sh/helm/v4/internal/test/ensure"
|
||||
chart "helm.sh/helm/v4/pkg/chart/v2"
|
||||
"helm.sh/helm/v4/pkg/chart/v2/loader"
|
||||
)
|
||||
|
|
@ -110,8 +111,8 @@ func TestPackage(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cachePath := t.TempDir()
|
||||
defer t.Chdir(cachePath)
|
||||
t.Chdir(t.TempDir())
|
||||
ensure.HelmHome(t)
|
||||
|
||||
if err := os.MkdirAll("toot", 0o777); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue