mirror of https://gitlab.com/gitlab-org/cli.git
35 lines
721 B
Go
35 lines
721 B
Go
package ci
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"gitlab.com/gitlab-org/cli/commands/cmdutils"
|
|
)
|
|
|
|
func TestPipelineCmd(t *testing.T) {
|
|
old := os.Stdout // keep backup of the real stdout
|
|
r, w, _ := os.Pipe()
|
|
os.Stdout = w
|
|
|
|
assert.Nil(t, NewCmdCI(&cmdutils.Factory{}).Execute())
|
|
|
|
outC := make(chan string)
|
|
// copy the output in a separate goroutine so printing can't block indefinitely
|
|
go func() {
|
|
var buf bytes.Buffer
|
|
_, _ = io.Copy(&buf, r)
|
|
outC <- buf.String()
|
|
}()
|
|
|
|
// back to normal state
|
|
w.Close()
|
|
os.Stdout = old // restoring the real stdout
|
|
out := <-outC
|
|
|
|
assert.Contains(t, out, "Use \"ci [command] --help\" for more information about a command.\n")
|
|
}
|