Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -85,3 +85,21 @@ func TestInSlice(t *testing.T) {
|
| 85 | 85 |
t.Fatalf("Expected string notinslice not to be in slice")
|
| 86 | 86 |
} |
| 87 | 87 |
} |
| 88 |
+ |
|
| 89 |
+func TestShellQuoteArgumentsEmpty(t *testing.T) {
|
|
| 90 |
+ actual := ShellQuoteArguments([]string{})
|
|
| 91 |
+ expected := "" |
|
| 92 |
+ if actual != expected {
|
|
| 93 |
+ t.Fatalf("Expected an empty string")
|
|
| 94 |
+ } |
|
| 95 |
+} |
|
| 96 |
+ |
|
| 97 |
+func TestShellQuoteArguments(t *testing.T) {
|
|
| 98 |
+ simpleString := "simpleString" |
|
| 99 |
+ complexString := "This is a 'more' complex $tring with some special char *" |
|
| 100 |
+ actual := ShellQuoteArguments([]string{simpleString, complexString})
|
|
| 101 |
+ expected := "simpleString 'This is a '\\''more'\\'' complex $tring with some special char *'" |
|
| 102 |
+ if actual != expected {
|
|
| 103 |
+ t.Fatalf("Expected \"%v\", got \"%v\"", expected, actual)
|
|
| 104 |
+ } |
|
| 105 |
+} |