test: fix TestConfigSSH_FileWriteAndOptionsFlow on Windows 11 24H2 (#17410)

Fixes tests on Windows 11 due to `printf` not being a recognized command name.
This commit is contained in:
Spike Curtis
2025-04-16 14:29:45 +04:00
committed by GitHub
parent 8cc743a812
commit b7cd545d0a

View File

@ -435,7 +435,7 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
"# :hostname-suffix=coder-suffix", "# :hostname-suffix=coder-suffix",
"# :header=X-Test-Header=foo", "# :header=X-Test-Header=foo",
"# :header=X-Test-Header2=bar", "# :header=X-Test-Header2=bar",
"# :header-command=printf h1=v1 h2=\"v2\" h3='v3'", "# :header-command=echo h1=v1 h2=\"v2\" h3='v3'",
"#", "#",
}, "\n"), }, "\n"),
strings.Join([]string{ strings.Join([]string{
@ -451,7 +451,7 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
"--hostname-suffix", "coder-suffix", "--hostname-suffix", "coder-suffix",
"--header", "X-Test-Header=foo", "--header", "X-Test-Header=foo",
"--header", "X-Test-Header2=bar", "--header", "X-Test-Header2=bar",
"--header-command", "printf h1=v1 h2=\"v2\" h3='v3'", "--header-command", "echo h1=v1 h2=\"v2\" h3='v3'",
}, },
}, },
{ {
@ -566,36 +566,36 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
name: "Header command", name: "Header command",
args: []string{ args: []string{
"--yes", "--yes",
"--header-command", "printf h1=v1", "--header-command", "echo h1=v1",
}, },
wantErr: false, wantErr: false,
hasAgent: true, hasAgent: true,
wantConfig: wantConfig{ wantConfig: wantConfig{
regexMatch: `ProxyCommand .* --header-command "printf h1=v1" ssh .* --ssh-host-prefix coder. %h`, regexMatch: `ProxyCommand .* --header-command "echo h1=v1" ssh .* --ssh-host-prefix coder. %h`,
}, },
}, },
{ {
name: "Header command with double quotes", name: "Header command with double quotes",
args: []string{ args: []string{
"--yes", "--yes",
"--header-command", "printf h1=v1 h2=\"v2\"", "--header-command", "echo h1=v1 h2=\"v2\"",
}, },
wantErr: false, wantErr: false,
hasAgent: true, hasAgent: true,
wantConfig: wantConfig{ wantConfig: wantConfig{
regexMatch: `ProxyCommand .* --header-command "printf h1=v1 h2=\\\"v2\\\"" ssh .* --ssh-host-prefix coder. %h`, regexMatch: `ProxyCommand .* --header-command "echo h1=v1 h2=\\\"v2\\\"" ssh .* --ssh-host-prefix coder. %h`,
}, },
}, },
{ {
name: "Header command with single quotes", name: "Header command with single quotes",
args: []string{ args: []string{
"--yes", "--yes",
"--header-command", "printf h1=v1 h2='v2'", "--header-command", "echo h1=v1 h2='v2'",
}, },
wantErr: false, wantErr: false,
hasAgent: true, hasAgent: true,
wantConfig: wantConfig{ wantConfig: wantConfig{
regexMatch: `ProxyCommand .* --header-command "printf h1=v1 h2='v2'" ssh .* --ssh-host-prefix coder. %h`, regexMatch: `ProxyCommand .* --header-command "echo h1=v1 h2='v2'" ssh .* --ssh-host-prefix coder. %h`,
}, },
}, },
{ {