From 5bd0ac371c68a53b1c78e01dbfc3473af0fc242a Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Wed, 18 May 2022 17:03:10 -0500 Subject: [PATCH] tests: Correct basis dir setup I noticed we were still catching the default locations for dirs in test and just appending a tempdir path inside of them. This fixes that and ensures all test files are contained within the tmpdir. --- internal/core/testing_basis.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/core/testing_basis.go b/internal/core/testing_basis.go index f1052733b..a65f657e0 100644 --- a/internal/core/testing_basis.go +++ b/internal/core/testing_basis.go @@ -4,6 +4,7 @@ import ( "context" "io/ioutil" "os" + "path/filepath" "github.com/hashicorp/vagrant-plugin-sdk/core" coremocks "github.com/hashicorp/vagrant-plugin-sdk/core/mocks" @@ -79,8 +80,20 @@ func TestBasis(t testing.T, opts ...BasisOption) (b *Basis) { require.NoError(t, err) t.Cleanup(func() { os.RemoveAll(td) }) - projDir, err := datadir.NewBasis(td) - require.NoError(t, err) + mkSubdir := func(root, sub string) string { + sd := filepath.Join(root, sub) + require.NoError(t, os.Mkdir(sd, 0755)) + return sd + } + + projDir := &datadir.Basis{ + Dir: datadir.NewBasicDir( + mkSubdir(td, "config"), + mkSubdir(td, "cache"), + mkSubdir(td, "data"), + mkSubdir(td, "temp"), + ), + } defaultOpts := []BasisOption{ WithClient(singleprocess.TestServer(t)),