github.com/nilium/gitlab-runner@v12.5.0+incompatible/shells/bash_test.go (about) 1 package shells 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestBash_CommandShellEscapes(t *testing.T) { 10 writer := &BashWriter{} 11 writer.Command("foo", "x&(y)") 12 13 assert.Equal(t, `$'foo' "x&(y)"`+"\n", writer.String()) 14 } 15 16 func TestBash_IfCmdShellEscapes(t *testing.T) { 17 writer := &BashWriter{} 18 writer.IfCmd("foo", "x&(y)") 19 20 assert.Equal(t, `if $'foo' "x&(y)" >/dev/null 2>/dev/null; then`+"\n", writer.String()) 21 }