Skip to content

Commit

Permalink
fix tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Apr 18, 2024
1 parent 5e14aed commit 0c46cd0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/pkg/packager/creator/normal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package creator

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -18,35 +19,37 @@ func TestDifferentialPackagePathSetCorrectly(t *testing.T) {
expected string
}

absolutePackagePath, err := filepath.Abs(filepath.Join("home", "cool-guy", "zarf-package", "my-package.tar.zst"))
require.NoError(t, err)

testCases := []testCase{
{
name: "relative path",
path: "my-package.tar.zst",
cwd: "/home/cool-guy/zarf-package",
expected: "/home/cool-guy/zarf-package/my-package.tar.zst",
cwd: filepath.Join("home", "cool-guy", "zarf-package"),
expected: filepath.Join("home", "cool-guy", "zarf-package", "my-package.tar.zst"),
},
{
name: "absolute path",
path: "/home/cool-guy/zarf-package/my-package.tar.zst",
cwd: "/home/cool-guy/zarf-package",
expected: "/home/cool-guy/zarf-package/my-package.tar.zst",
path: absolutePackagePath,
cwd: filepath.Join("home", "should-not-matter"),
expected: absolutePackagePath,
},
{
name: "oci path",
path: "oci://my-cool-registry.com:555/my-package.tar.zst",
cwd: "/home/cool-guy/zarf-package",
cwd: filepath.Join("home", "should-not-matter"),
expected: "oci://my-cool-registry.com:555/my-package.tar.zst",
},
{
name: "https path",
path: "https://neat-url.com/zarf-init-amd64-v1.0.0.tar.zst",
cwd: "/home/cool-guy/zarf-package",
cwd: filepath.Join("home", "should-not-matter"),
expected: "https://neat-url.com/zarf-init-amd64-v1.0.0.tar.zst",
},
}
for _, testCase := range testCases {
tc := testCase

t.Run(tc.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, tc.expected, updateRelativeDifferentialPackagePath(tc.path, tc.cwd))
Expand Down

0 comments on commit 0c46cd0

Please sign in to comment.