Tests are passing

pull/6580/head
Wheeler Law 8 years ago committed by Megan Marsh
parent de3bdec567
commit 1fdce9dada

@ -257,7 +257,7 @@ func funcGenVault(ctx *Context) interface{} {
} }
func funcGenSed(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)) engine, err := sed.New(strings.NewReader(expression))
if err != nil { if err != nil {
@ -266,6 +266,14 @@ func funcGenSed(ctx *Context) interface{} {
result, err := engine.RunString(inputString) 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 return result, err
} }
} }

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

Loading…
Cancel
Save