From 20a077b16c8ee8a91bb6eeb6ebb268444f1c2841 Mon Sep 17 00:00:00 2001 From: Daksha1611 Date: Fri, 18 Sep 2026 20:36:13 +0530 Subject: [PATCH] pkg/bindings/images: fix TestConvertAdditionalBuildContexts on non-Windows hosts TestConvertAdditionalBuildContexts asserted that the additional build context "C:\test" is rewritten to "/mnt/c/test". That rewrite is done by specgen.ConvertWinMountPath, which is a no-op unless shouldResolveWinPaths() is true: always on Windows, but on Linux only when the client runs inside a WSL or Hyper-V guest. On an ordinary Linux host the value is passed through unchanged and the test fails. Keep the platform independent expectations (URLs, images and unix paths are never rewritten) in the shared test and move the drive letter case to a Windows only file, following the existing split in pkg/specgen. Signed-off-by: Daksha1611 --- pkg/bindings/images/build_test.go | 10 +++------- pkg/bindings/images/build_windows_test.go | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 pkg/bindings/images/build_windows_test.go diff --git a/pkg/bindings/images/build_test.go b/pkg/bindings/images/build_test.go index 378a3a3d3d..58bcce2e94 100644 --- a/pkg/bindings/images/build_test.go +++ b/pkg/bindings/images/build_test.go @@ -17,14 +17,11 @@ func TestBuildNotMatchStatusMessage(t *testing.T) { assert.False(t, iidRegex.MatchString("Copying config a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4")) } +// Windows host paths are only rewritten when the client runs on Windows or +// inside a WSL/Hyper-V guest, so the drive letter case is covered separately in +// build_windows_test.go. The values below are left alone on every platform. func TestConvertAdditionalBuildContexts(t *testing.T) { additionalBuildContexts := map[string]*define.AdditionalBuildContext{ - "context1": { - IsURL: false, - IsImage: false, - Value: "C:\\test", - DownloadedCache: "", - }, "context2": { IsURL: false, IsImage: false, @@ -48,7 +45,6 @@ func TestConvertAdditionalBuildContexts(t *testing.T) { convertAdditionalBuildContexts(additionalBuildContexts) expectedGuestValues := map[string]string{ - "context1": "/mnt/c/test", "context2": "/test", "context3": "https://a.com/b.tar", "context4": "quay.io/a/b:c", diff --git a/pkg/bindings/images/build_windows_test.go b/pkg/bindings/images/build_windows_test.go new file mode 100644 index 0000000000..b93c30d27d --- /dev/null +++ b/pkg/bindings/images/build_windows_test.go @@ -0,0 +1,23 @@ +package images + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "go.podman.io/buildah/define" +) + +func TestConvertAdditionalBuildContextsWindowsPath(t *testing.T) { + additionalBuildContexts := map[string]*define.AdditionalBuildContext{ + "context1": { + IsURL: false, + IsImage: false, + Value: "C:\\test", + DownloadedCache: "", + }, + } + + convertAdditionalBuildContexts(additionalBuildContexts) + + assert.Equal(t, "/mnt/c/test", additionalBuildContexts["context1"].Value) +}