cli/commands/ci/ci_test.go

35 lines
721 B
Go
Raw Normal View History

2020-12-16 19:06:34 +00:00
package ci
2020-08-15 08:39:03 +00:00
import (
"bytes"
"io"
"os"
2020-08-15 08:39:03 +00:00
"testing"
"github.com/stretchr/testify/assert"
2022-09-19 20:23:45 +00:00
"gitlab.com/gitlab-org/cli/commands/cmdutils"
2020-08-15 08:39:03 +00:00
)
Isolate commands into separate sub-packages (#229) * refactor: organize commands into separate subfolders * Format code with gofmt This commit fixes the style issues introduced in d1f70d5 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/1ce57d1c-4f1e-48c2-a4d8-00c1bce7fb49/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in ca0bff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/11379011-98c6-43ea-8baa-4fefa9b775e4/ * 🔥 sub-packaging * Format code with gofmt This commit fixes the style issues introduced in 00e5936 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/c912f945-acf3-48d2-a550-0895c0153df0/ * Done with sub-packaging 🔥 * 🔥 tests * Format code with gofmt This commit fixes the style issues introduced in 56a8ff4 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/24498865-4980-479f-90c7-7ddd228c2bb4/ * fix bug risks * fix tests * fix tests * Format code with gofmt This commit fixes the style issues introduced in c947d02 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/cb2ac46a-f857-40d5-8508-eacc253b3614/ * Format code with gofmt This commit fixes the style issues introduced in 902ff7b according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f60ba0d6-94d3-47c0-ae27-568a5cc5d9e5/ * fix tests * fix tests * 🔥 gookit/color * Format code with gofmt This commit fixes the style issues introduced in 5a129ea according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/8f1c8327-f5c6-4ff5-97d2-3c8a23f0a1e2/ * Autofix issues in 1 files Resolved issues in the following files via DeepSource Autofix: 1. commands/cmdtest/helper.go * add tests for MR * Format code with gofmt This commit fixes the style issues introduced in 758af28 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/d55a4867-aa23-4202-b2cc-a7ceafbaa53e/ * migrate old config to new config * fix bug risks * Format code with gofmt This commit fixes the style issues introduced in 0ea8eb2 according to the output from gofmt. Details: https://deepsource.io/gh/profclems/glab/transform/f90cf664-8396-4b78-814d-3167ce898164/ * refactoring Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-29 05:55:34 +00:00
func TestPipelineCmd(t *testing.T) {
old := os.Stdout // keep backup of the real stdout
r, w, _ := os.Pipe()
os.Stdout = w
2020-12-16 19:06:34 +00:00
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
2021-01-29 11:36:53 +00:00
_, _ = io.Copy(&buf, r)
outC <- buf.String()
}()
// back to normal state
w.Close()
os.Stdout = old // restoring the real stdout
out := <-outC
2020-12-21 12:21:59 +00:00
assert.Contains(t, out, "Use \"ci [command] --help\" for more information about a command.\n")
2020-08-15 12:50:25 +00:00
}