func (S) TestWrite(c *C) { var b bytes.Buffer p := pipe.Line( pipe.Print("hello"), pipe.Exec("sed", "s/l/k/g"), pipe.Write(&b), ) output, err := pipe.Output(p) c.Assert(err, IsNil) c.Assert(string(output), Equals, "") c.Assert(b.String(), Equals, "hekko") }
func (S) TestScriptNesting(c *C) { b := &bytes.Buffer{} p := pipe.Line( pipe.Print("hello"), pipe.Script( pipe.Print("world"), pipe.Exec("sed", "s/l/k/g"), ), pipe.Write(b), ) err := pipe.Run(p) c.Assert(err, IsNil) c.Assert(b.String(), Equals, "worldhekko") }
func (S) TestLineNesting(c *C) { b := &bytes.Buffer{} p := pipe.Line( pipe.Print("hello"), pipe.Line( pipe.Filter(func(line []byte) bool { return true }), pipe.Exec("sed", "s/l/k/g"), ), pipe.Write(b), ) err := pipe.Run(p) c.Assert(err, IsNil) c.Assert(b.String(), Equals, "hekko") }