From deb54ede2e3c71ca604ee27c518880c2301a6b52 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 29 May 2015 15:49:29 +0200 Subject: [PATCH] Add test coverage for pkg/stringutils Signed-off-by: Vincent Demeester --- stringutils/stringutils_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/stringutils/stringutils_test.go b/stringutils/stringutils_test.go index 8dcb469..124b255 100644 --- a/stringutils/stringutils_test.go +++ b/stringutils/stringutils_test.go @@ -85,3 +85,21 @@ func TestInSlice(t *testing.T) { t.Fatalf("Expected string notinslice not to be in slice") } } + +func TestShellQuoteArgumentsEmpty(t *testing.T) { + actual := ShellQuoteArguments([]string{}) + expected := "" + if actual != expected { + t.Fatalf("Expected an empty string") + } +} + +func TestShellQuoteArguments(t *testing.T) { + simpleString := "simpleString" + complexString := "This is a 'more' complex $tring with some special char *" + actual := ShellQuoteArguments([]string{simpleString, complexString}) + expected := "simpleString 'This is a '\\''more'\\'' complex $tring with some special char *'" + if actual != expected { + t.Fatalf("Expected \"%v\", got \"%v\"", expected, actual) + } +}