Tests are passing

This commit is contained in:
Wheeler Law 2018-08-15 22:48:20 -04:00 committed by Megan Marsh
parent de3bdec567
commit 1fdce9dada
2 changed files with 11 additions and 3 deletions

View File

@ -257,7 +257,7 @@ func funcGenVault(ctx *Context) interface{} {
}
func funcGenSed(ctx *Context) interface{} {
return func(inputString string, expression string) (string, error) {
return func(expression string, inputString string) (string, error) {
engine, err := sed.New(strings.NewReader(expression))
if err != nil {
@ -266,6 +266,14 @@ func funcGenSed(ctx *Context) interface{} {
result, err := engine.RunString(inputString)
if err != nil{
return "", err
}
// The sed library adds a \n to all processed strings.
resultLength := len(result)
result = result[:resultLength-1]
return result, err
}
}

View File

@ -322,12 +322,12 @@ func TestFuncSed(t *testing.T) {
Output string
}{
{
`{{sed "hello" "s|hello|world|"}}`,
`{{sed "s|hello|world|" "hello"}}`,
`world`,
},
{
`{{sed "hello" "s|foo|bar|"}}`,
`{{sed "s|foo|bar|" "hello"}}`,
`hello`,
},