Skip to content

Commit

Permalink
fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Jun 24, 2024
1 parent 67d610e commit e1c74ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{}),
},
}

Expand All @@ -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)
Expand Down
44 changes: 0 additions & 44 deletions src/pkg/packager/creator/normal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
})
}
}

0 comments on commit e1c74ae

Please sign in to comment.