github.com/ssube/gitlab-ci-multi-runner@v1.2.1-0.20160607142738-b8d1285632e6/helpers/shell_escape_test.go (about) 1 package helpers 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6 ) 7 8 func TestShellEscape(t *testing.T) { 9 var tests = []struct { 10 in string 11 out string 12 }{ 13 {"standard string", "$'standard string'"}, 14 {"+\t\n\r&", "$'+\\t\\n\\r&'"}, 15 {"", "''"}, 16 } 17 18 for _, test := range tests { 19 actual := ShellEscape(test.in) 20 assert.Equal(t, test.out, actual, "src=%v", test.in) 21 } 22 } 23 24 func TestToBackslash(t *testing.T) { 25 26 result := ToBackslash("smb://user/me/directory") 27 expected := "smb:\\\\user\\me\\directory" 28 29 if result != expected { 30 t.Error("Expected", expected, ", got ", result) 31 } 32 } 33 34 func TestToSlash(t *testing.T) { 35 36 result := ToSlash("smb:\\\\user\\me\\directory") 37 expected := "smb://user/me/directory" 38 39 if result != expected { 40 t.Error("Expected", expected, ", got ", result) 41 } 42 }