Skip to content

Commit

Permalink
Update tests for OCI to run on Windows and test slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 committed Nov 1, 2023
1 parent 0a4393b commit 054e3dd
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/pkg/layout/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (pp *PackagePaths) SetFromLayers(layers []ocispec.Descriptor) {
func (pp *PackagePaths) SetFromPaths(paths []string) {
for _, rel := range paths {
// Convert from the standard '/' to the OS path separator for Windows support
switch path := filepath.FromSlash(rel); {
switch path := rel; { // filepath.FromSlash(rel); {
case path == ZarfYAML:
pp.ZarfYAML = filepath.Join(pp.Base, path)
case path == Signature:
Expand Down Expand Up @@ -218,7 +218,7 @@ func (pp *PackagePaths) Files() map[string]string {
stripBase := func(path string) string {
rel, _ := filepath.Rel(pp.Base, path)
// Convert from the OS path separator to the standard '/' for Windows support
return filepath.ToSlash(rel)
return rel //filepath.ToSlash(rel)
}

add := func(path string) {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/oci/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewZarfOCIManifest(manifest *ocispec.Manifest) *ZarfOCIManifest {
func (m *ZarfOCIManifest) Locate(pathOrDigest string) ocispec.Descriptor {
return helpers.Find(m.Layers, func(layer ocispec.Descriptor) bool {
// Convert from the OS path separator to the standard '/' for Windows support
return layer.Annotations[ocispec.AnnotationTitle] == filepath.ToSlash(pathOrDigest) || layer.Digest.Encoded() == pathOrDigest
return layer.Annotations[ocispec.AnnotationTitle] == pathOrDigest || layer.Digest.Encoded() == pathOrDigest // filepath.ToSlash(pathOrDigest) || layer.Digest.Encoded() == pathOrDigest
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/pkg/oci/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
// FileDescriptorExists returns true if the given file exists in the given directory with the expected SHA.
func (o *OrasRemote) FileDescriptorExists(desc ocispec.Descriptor, destinationDir string) bool {
// Convert from the standard '/' to the OS path separator for Windows support
rel := filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])
rel := desc.Annotations[ocispec.AnnotationTitle] // filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])
destinationPath := filepath.Join(destinationDir, rel)

info, err := os.Stat(destinationPath)
Expand Down Expand Up @@ -257,7 +257,7 @@ func (o *OrasRemote) PullLayer(desc ocispec.Descriptor, destinationDir string) e
}

// Convert from the standard '/' to the OS path separator for Windows support
rel := filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])
rel := desc.Annotations[ocispec.AnnotationTitle] // filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])

return utils.WriteFile(filepath.Join(destinationDir, rel), b)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func (p *Packager) generatePackageChecksums() (string, error) {
}

// Convert from the OS path separator to '/' for Windows support
rel = filepath.ToSlash(rel)
// rel = filepath.ToSlash(rel)

sum, err := utils.GetSHA256OfFile(abs)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/packager/sources/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func ValidatePackageIntegrity(loaded *layout.PackagePaths, aggregateChecksum str
sha := split[0]

// Convert from the standard '/' to the OS path separator for Windows support
rel := filepath.FromSlash(split[1])
rel := split[1] // filepath.FromSlash(split[1])

if sha == "" || rel == "" {
return fmt.Errorf("invalid checksum line: %s", line)
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/09_component_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,5 @@ func (suite *CompositionSuite) Test_1_FullComposability() {
}

func TestCompositionSuite(t *testing.T) {
e2e.SetupWithCluster(t)

suite.Run(t, new(CompositionSuite))
}
2 changes: 0 additions & 2 deletions src/test/e2e/10_component_flavor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,5 @@ func (suite *FlavorSuite) Test_1_FlavorArchFiltering() {
}

func TestFlavorSuite(t *testing.T) {
e2e.SetupWithCluster(t)

suite.Run(t, new(FlavorSuite))
}

0 comments on commit 054e3dd

Please sign in to comment.