Skip to content

Commit 28d4270

Browse files
committed
fix(test): make value-file resolution tests cross-platform on Windows
The absolute-passthrough fixtures used bare /-rooted paths, which are not filepath.IsAbs on Windows (no volume), so resolveProjectValueFiles re-joined them against the project root and the assertions failed on windows-latest. Use the crossPlatformAbs helper for the absolute fixtures and filepath.Join for the expected joined paths so the host path separator matches what the resolver emits. Production behaviour is unchanged; a real C:-rooted path was already handled correctly. Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent dc95e9a commit 28d4270

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎pkg/commands/contract_apply_values_test.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package commands
1616

1717
import (
18+
"path/filepath"
1819
"slices"
1920
"testing"
2021
)
@@ -97,15 +98,20 @@ func TestSetApplyValueOptions_ResolvesConfigValueFilesAgainstRoot(t *testing.T)
9798
restore := snapshotApplyValueState()
9899
defer restore()
99100

101+
// crossPlatformAbs so the config-origin absolute entry satisfies
102+
// filepath.IsAbs on Windows too; want[0] uses filepath.Join to match the
103+
// host separator the resolver emits.
104+
absExtra := crossPlatformAbs("abs", "extra.yaml")
105+
100106
Config.RootDir = testProjectRoot
101-
Config.TemplateOptions.ValueFiles = []string{"values-secret.encrypted.yaml", "/abs/extra.yaml"}
107+
Config.TemplateOptions.ValueFiles = []string{"values-secret.encrypted.yaml", absExtra}
102108
applyCmdFlags.valueFiles = []string{"cli-relative.yaml"}
103109

104110
opts := buildApplyRenderOptions([]string{testTemplateControlplaneRel}, testProjectRoot+"/secrets.yaml")
105111

106112
want := []string{
107-
testProjectRoot + "/values-secret.encrypted.yaml", // config-origin relative → joined with root
108-
"/abs/extra.yaml", // config-origin absolute → passthrough
113+
filepath.Join(testProjectRoot, "values-secret.encrypted.yaml"), // config-origin relative → joined with root
114+
absExtra, // config-origin absolute → passthrough
109115
"cli-relative.yaml", // CLI-origin → CWD-relative, appended last
110116
}
111117
if !slices.Equal(opts.ValueFiles, want) {

‎pkg/commands/contract_value_path_resolution_test.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import (
2525
// (so they resolve identically from any CWD, like ResolveSecretsPath), and
2626
// absolute entries pass through unchanged. An empty input yields nil.
2727
func TestResolveProjectValueFiles(t *testing.T) {
28-
abs := filepath.Join(testProjectRoot, "abs.yaml")
28+
// crossPlatformAbs so the "absolute passthrough" cases use a path that
29+
// satisfies filepath.IsAbs on Windows too (a bare /project is not absolute
30+
// without a volume there, so resolveProjectValueFiles would re-join it).
31+
abs := crossPlatformAbs("project", "abs.yaml")
2932

3033
cases := []struct {
3134
name string

0 commit comments

Comments
 (0)