From 0c46cd039113d4e35c108c1b64c8c89332222b35 Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Thu, 18 Apr 2024 15:58:32 +0000 Subject: [PATCH] fix tests for windows --- src/pkg/packager/creator/normal_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pkg/packager/creator/normal_test.go b/src/pkg/packager/creator/normal_test.go index c07ee666ba..9a4830cb1f 100644 --- a/src/pkg/packager/creator/normal_test.go +++ b/src/pkg/packager/creator/normal_test.go @@ -5,6 +5,7 @@ package creator import ( + "path/filepath" "testing" "github.com/stretchr/testify/require" @@ -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))