Tests are passing
This commit is contained in:
parent
de3bdec567
commit
1fdce9dada
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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`,
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue