From 5240e1403a5041221204f460c87ed886d919a80a Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Fri, 8 Feb 2019 13:22:46 +0200 Subject: [PATCH] Support custom command in pipeline --- pipeline.go | 6 ++++++ pipeline_test.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/pipeline.go b/pipeline.go index ba85228..67f38ab 100644 --- a/pipeline.go +++ b/pipeline.go @@ -31,6 +31,12 @@ type Pipeline struct { closed bool } +func (c *Pipeline) Do(args ...interface{}) *Cmd { + cmd := NewCmd(args...) + _ = c.Process(cmd) + return cmd +} + // Process queues the cmd for later execution. func (c *Pipeline) Process(cmd Cmder) error { c.mu.Lock() diff --git a/pipeline_test.go b/pipeline_test.go index 11896c6..0d7b83e 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -60,6 +60,13 @@ var _ = Describe("pipelining", func() { Expect(err).NotTo(HaveOccurred()) Expect(val).To(Equal("value")) }) + + It("supports custom command", func() { + pipe.Do("ping") + cmds, err := pipe.Exec() + Expect(err).NotTo(HaveOccurred()) + Expect(cmds).To(HaveLen(1)) + }) } Describe("Pipeline", func() {