github.com/alloyci/alloy-runner@v1.0.1-0.20180222164613-925503ccafd6/shells/powershell_test.go (about)

     1  package shells
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestPowershell_CommandShellEscapes(t *testing.T) {
    10  	writer := &PsWriter{}
    11  	writer.Command("foo", "x&(y)")
    12  
    13  	assert.Equal(t, "& \"foo\" \"x&(y)\"\r\nif(!$?) { Exit $LASTEXITCODE }\r\n\r\n", writer.String())
    14  }
    15  
    16  func TestPowershell_IfCmdShellEscapes(t *testing.T) {
    17  	writer := &PsWriter{}
    18  	writer.IfCmd("foo", "x&(y)")
    19  
    20  	assert.Equal(t, "& \"foo\" \"x&(y)\" 2>$null\r\nif($?) {\r\n", writer.String())
    21  }