summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/common_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-01 12:45:11 -0500
committerGitHub <noreply@github.com>2021-02-01 12:45:11 -0500
commit182e8414d406d3058e985104af98f30a9e8f56fa (patch)
tree7ce06e9fab81e63476b43bcefa746520abdf7b91 /pkg/systemd/generate/common_test.go
parent20183349fd2c6a9a569c6c79234af48bb5d92ff7 (diff)
parent5352df226bc3f345836e78b73063de91d34b4e85 (diff)
downloadpodman-182e8414d406d3058e985104af98f30a9e8f56fa.tar.gz
podman-182e8414d406d3058e985104af98f30a9e8f56fa.tar.bz2
podman-182e8414d406d3058e985104af98f30a9e8f56fa.zip
Merge pull request #9178 from Luap99/fix-9176
Fix podman generate systemd --new special char handling
Diffstat (limited to 'pkg/systemd/generate/common_test.go')
-rw-r--r--pkg/systemd/generate/common_test.go40
1 files changed, 38 insertions, 2 deletions
diff --git a/pkg/systemd/generate/common_test.go b/pkg/systemd/generate/common_test.go
index d0ec5637c..a0691d1ad 100644
--- a/pkg/systemd/generate/common_test.go
+++ b/pkg/systemd/generate/common_test.go
@@ -29,7 +29,7 @@ func TestFilterPodFlags(t *testing.T) {
}
}
-func TestQuoteArguments(t *testing.T) {
+func TestEscapeSystemdArguments(t *testing.T) {
tests := []struct {
input []string
output []string
@@ -46,10 +46,46 @@ func TestQuoteArguments(t *testing.T) {
[]string{"foo", "bar=\"arg with\ttab\""},
[]string{"foo", "\"bar=\\\"arg with\\ttab\\\"\""},
},
+ {
+ []string{"$"},
+ []string{"$$"},
+ },
+ {
+ []string{"foo", "command with dollar sign $"},
+ []string{"foo", "\"command with dollar sign $$\""},
+ },
+ {
+ []string{"foo", "command with two dollar signs $$"},
+ []string{"foo", "\"command with two dollar signs $$$$\""},
+ },
+ {
+ []string{"%"},
+ []string{"%%"},
+ },
+ {
+ []string{"foo", "command with percent sign %"},
+ []string{"foo", "\"command with percent sign %%\""},
+ },
+ {
+ []string{"foo", "command with two percent signs %%"},
+ []string{"foo", "\"command with two percent signs %%%%\""},
+ },
+ {
+ []string{`\`},
+ []string{`\\`},
+ },
+ {
+ []string{"foo", `command with backslash \`},
+ []string{"foo", `"command with backslash \\"`},
+ },
+ {
+ []string{"foo", `command with two backslashs \\`},
+ []string{"foo", `"command with two backslashs \\\\"`},
+ },
}
for _, test := range tests {
- quoted := quoteArguments(test.input)
+ quoted := escapeSystemdArguments(test.input)
assert.Equal(t, test.output, quoted)
}
}