diff --git a/index/new_test.go b/index/new_test.go index bcd745fc..cd5c825a 100644 --- a/index/new_test.go +++ b/index/new_test.go @@ -13,19 +13,28 @@ import ( ) func TestRemoteNew(t *testing.T) { - spec.Run(t, "RemoteNew", testRemoteNew, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "RemoteNew", testRemoteNew, spec.Parallel(), spec.Report(report.Terminal{})) } func testRemoteNew(t *testing.T, when spec.G, it spec.S) { + var ( + idx imgutil.ImageIndex + xdgPath string + err error + ) + + it.Before(func() { + // creates the directory to save all the OCI images on disk + xdgPath, err = os.MkdirTemp("", "image-indexes") + h.AssertNil(t, err) + }) + + it.After(func() { + err := os.RemoveAll(xdgPath) + h.AssertNil(t, err) + }) + when("#NewIndex", func() { - var ( - idx imgutil.ImageIndex - err error - xdgPath = "xdgPath" - ) - it.After(func() { - h.AssertNil(t, os.RemoveAll(xdgPath)) - }) it("should have expected indexOptions", func() { idx, err = index.NewIndex("repo/name", index.WithInsecure(true), index.WithXDGRuntimePath(xdgPath)) h.AssertNil(t, err) diff --git a/index/options_test.go b/index/options_test.go index e2835a26..0c965cb9 100644 --- a/index/options_test.go +++ b/index/options_test.go @@ -12,7 +12,7 @@ import ( ) func TestRemoteOptions(t *testing.T) { - spec.Run(t, "RemoteNew", testRemoteOptions, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "RemoteNew", testRemoteOptions, spec.Parallel(), spec.Report(report.Terminal{})) } func testRemoteOptions(t *testing.T, when spec.G, it spec.S) { diff --git a/layout/new_test.go b/layout/new_test.go index 94670aca..8573c5fc 100644 --- a/layout/new_test.go +++ b/layout/new_test.go @@ -1,6 +1,7 @@ package layout_test import ( + "os" "testing" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -15,17 +16,31 @@ import ( ) func TestRemoteNew(t *testing.T) { - spec.Run(t, "RemoteNew", testRemoteNew, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "RemoteNew", testRemoteNew, spec.Parallel(), spec.Report(report.Terminal{})) } var ( - xdgPath = "xdgPath" repoName = "some/index" - idx imgutil.ImageIndex - err error ) func testRemoteNew(t *testing.T, when spec.G, it spec.S) { + var ( + idx imgutil.ImageIndex + xdgPath string + err error + ) + + it.Before(func() { + // creates the directory to save all the OCI images on disk + xdgPath, err = os.MkdirTemp("", "image-indexes") + h.AssertNil(t, err) + }) + + it.After(func() { + err := os.RemoveAll(xdgPath) + h.AssertNil(t, err) + }) + when("#NewIndex", func() { it.Before(func() { idx, err = index.NewIndex( diff --git a/local/new_test.go b/local/new_test.go index ef933f0f..200859af 100644 --- a/local/new_test.go +++ b/local/new_test.go @@ -1,6 +1,7 @@ package local_test import ( + "os" "testing" v1 "github.com/google/go-containerregistry/pkg/v1" @@ -15,19 +16,31 @@ import ( ) func TestRemoteNew(t *testing.T) { - spec.Run(t, "RemoteNew", testRemoteNew, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "RemoteNew", testRemoteNew, spec.Parallel(), spec.Report(report.Terminal{})) } var ( - xdgPath = "xdgPath" repoName = "some/index" ) func testRemoteNew(t *testing.T, when spec.G, it spec.S) { var ( - idx imgutil.ImageIndex - err error + idx imgutil.ImageIndex + xdgPath string + err error ) + + it.Before(func() { + // creates the directory to save all the OCI images on disk + xdgPath, err = os.MkdirTemp("", "image-indexes") + h.AssertNil(t, err) + }) + + it.After(func() { + err := os.RemoveAll(xdgPath) + h.AssertNil(t, err) + }) + when("#NewIndex", func() { it.Before(func() { idx, err = index.NewIndex( diff --git a/remote/new_test.go b/remote/new_test.go index b185c4e9..1df37920 100644 --- a/remote/new_test.go +++ b/remote/new_test.go @@ -16,13 +16,26 @@ import ( ) func TestRemoteNew(t *testing.T) { - spec.Run(t, "RemoteNew", testRemoteNew, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "RemoteNew", testRemoteNew, spec.Parallel(), spec.Report(report.Terminal{})) } func testRemoteNew(t *testing.T, when spec.G, it spec.S) { var ( - xdgPath = "xdgPath" + xdgPath string + err error ) + + it.Before(func() { + // creates the directory to save all the OCI images on disk + xdgPath, err = os.MkdirTemp("", "image-indexes") + h.AssertNil(t, err) + }) + + it.After(func() { + err := os.RemoveAll(xdgPath) + h.AssertNil(t, err) + }) + when("#NewIndex", func() { it.After(func() { err := os.RemoveAll(xdgPath) diff --git a/util_test.go b/util_test.go index ce91b408..17db8df5 100644 --- a/util_test.go +++ b/util_test.go @@ -15,7 +15,7 @@ import ( ) func TestUtils(t *testing.T) { - spec.Run(t, "Utils", testUtils, spec.Sequential(), spec.Report(report.Terminal{})) + spec.Run(t, "Utils", testUtils, spec.Parallel(), spec.Report(report.Terminal{})) } type FakeIndentifier struct {