From e1c74ae05418f149818e2017e299142897923893 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Mon, 24 Jun 2024 17:01:15 +0000 Subject: [PATCH] fix name --- .../{skeleton_test.go => creator_test.go} | 21 +++++++-- src/pkg/packager/creator/normal_test.go | 44 ------------------- 2 files changed, 17 insertions(+), 48 deletions(-) rename src/pkg/packager/creator/{skeleton_test.go => creator_test.go} (60%) diff --git a/src/pkg/packager/creator/skeleton_test.go b/src/pkg/packager/creator/creator_test.go similarity index 60% rename from src/pkg/packager/creator/skeleton_test.go rename to src/pkg/packager/creator/creator_test.go index ca2e9cd352..18a4a64c0a 100644 --- a/src/pkg/packager/creator/skeleton_test.go +++ b/src/pkg/packager/creator/creator_test.go @@ -14,23 +14,37 @@ import ( "github.com/stretchr/testify/require" ) -func TestSkeletonLoadPackageDefinition(t *testing.T) { +func TestLoadPackageDefinition(t *testing.T) { t.Parallel() - tests := []struct { name string testDir string expectedErr string + creator Creator }{ { name: "valid package definition", testDir: "valid", expectedErr: "", + creator: NewPackageCreator(types.ZarfCreateOptions{}, ""), + }, + { + name: "invalid package definition", + testDir: "invalid", + expectedErr: "package must have at least 1 component", + creator: NewPackageCreator(types.ZarfCreateOptions{}, ""), + }, + { + name: "valid package definition", + testDir: "valid", + expectedErr: "", + creator: NewSkeletonCreator(types.ZarfCreateOptions{}, types.ZarfPublishOptions{}), }, { name: "invalid package definition", testDir: "invalid", expectedErr: "package must have at least 1 component", + creator: NewSkeletonCreator(types.ZarfCreateOptions{}, types.ZarfPublishOptions{}), }, } @@ -40,8 +54,7 @@ func TestSkeletonLoadPackageDefinition(t *testing.T) { t.Parallel() src := layout.New(filepath.Join("testdata", tt.testDir)) - sc := NewSkeletonCreator(types.ZarfCreateOptions{}, types.ZarfPublishOptions{}) - pkg, _, err := sc.LoadPackageDefinition(context.Background(), src) + pkg, _, err := tt.creator.LoadPackageDefinition(context.Background(), src) if tt.expectedErr == "" { require.NoError(t, err) diff --git a/src/pkg/packager/creator/normal_test.go b/src/pkg/packager/creator/normal_test.go index 32b1a2ce4b..9a4830cb1f 100644 --- a/src/pkg/packager/creator/normal_test.go +++ b/src/pkg/packager/creator/normal_test.go @@ -5,12 +5,9 @@ package creator import ( - "context" "path/filepath" "testing" - "github.com/defenseunicorns/zarf/src/pkg/layout" - "github.com/defenseunicorns/zarf/src/types" "github.com/stretchr/testify/require" ) @@ -59,44 +56,3 @@ func TestDifferentialPackagePathSetCorrectly(t *testing.T) { }) } } - -func TestLoadPackageDefinition(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - testDir string - expectedErr string - }{ - { - name: "valid package definition", - testDir: "valid", - expectedErr: "", - }, - { - name: "invalid package definition", - testDir: "invalid", - expectedErr: "package must have at least 1 component", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - src := layout.New(filepath.Join("testdata", tt.testDir)) - pc := NewPackageCreator(types.ZarfCreateOptions{}, "") - pkg, _, err := pc.LoadPackageDefinition(context.Background(), src) - - if tt.expectedErr == "" { - require.NoError(t, err) - require.NotEmpty(t, pkg) - return - } - - require.EqualError(t, err, tt.expectedErr) - require.Empty(t, pkg) - }) - } -}