scriptx/subpipe_test.go

26 lines
537 B
Go

package scriptx_test
import (
"testing"
"github.com/bitfield/script"
"lmika.dev/pkg/scriptx"
)
func TestSubPipe(t *testing.T) {
t.Run("should run the subpipe for each line in the parent pipe", func(t *testing.T) {
verifyPipeLines(t, func(p *script.Pipe) *script.Pipe {
return p.Filter(scriptx.SubPipe(func(line string) *script.Pipe {
return script.Echo(line).Replace("Line", "Subpipe")
}))
}, []string{
"Line 1",
"Line 2",
"Line 3",
}, []string{
"Subpipe 1",
"Subpipe 2",
"Subpipe 3",
})
})
}