mirror of https://gitlab.com/gitlab-org/cli.git
(test): run ci lint integration test
This commit is contained in:
parent
e2d4485281
commit
aa0cc8bcf5
|
@ -3,6 +3,10 @@ package lint
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/gitlab-org/cli/pkg/iostreams"
|
||||
"gitlab.com/gitlab-org/cli/test"
|
||||
|
||||
"gitlab.com/gitlab-org/cli/commands/cmdtest"
|
||||
)
|
||||
|
||||
|
@ -11,53 +15,45 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
|
||||
func Test_pipelineCILint_Integration(t *testing.T) {
|
||||
// TODO: This test is temporarily disabled because of
|
||||
// https://gitlab.com/gitlab-org/cli/-/issues/1105
|
||||
glTestHost := test.GetHostOrSkip(t)
|
||||
|
||||
// glTestHost := test.GetHostOrSkip(t)
|
||||
//
|
||||
// io, _, stdout, stderr := iostreams.Test()
|
||||
// fac := cmdtest.StubFactory(glTestHost)
|
||||
// fac.IO = io
|
||||
// fac.IO.StdErr = stderr
|
||||
// fac.IO.StdOut = stdout
|
||||
//
|
||||
// tests := []struct {
|
||||
// Name string
|
||||
// Args string
|
||||
// StdOut string
|
||||
// StdErr string
|
||||
// WantErr error
|
||||
// }{
|
||||
// {
|
||||
// Name: "with no path specified",
|
||||
// Args: "",
|
||||
// StdOut: "✓ CI/CD YAML is valid!\n",
|
||||
// StdErr: "Getting contents in .gitlab-ci.yml\nValidating...\n",
|
||||
// },
|
||||
// {
|
||||
// Name: "with path specified as url",
|
||||
// Args: glTestHost + "/gitlab-org/cli/-/raw/main/.gitlab-ci.yml",
|
||||
// StdOut: "✓ CI/CD YAML is valid!\n",
|
||||
// StdErr: "Getting contents in " + glTestHost + "/gitlab-org/cli/-/raw/main/.gitlab-ci.yml\nValidating...\n",
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// cmd := NewCmdLint(fac)
|
||||
//
|
||||
// for _, test := range tests {
|
||||
// t.Run(test.Name, func(t *testing.T) {
|
||||
// _, err := cmdtest.RunCommand(cmd, test.Args)
|
||||
// if err != nil {
|
||||
// if test.WantErr == nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// assert.Equal(t, err, test.WantErr)
|
||||
// }
|
||||
// assert.Equal(t, test.StdErr, stderr.String())
|
||||
// assert.Equal(t, test.StdOut, stdout.String())
|
||||
// stdout.Reset()
|
||||
// stderr.Reset()
|
||||
// })
|
||||
// }
|
||||
io, _, stdout, stderr := iostreams.Test()
|
||||
fac := cmdtest.StubFactory(glTestHost + "/cli-automated-testing/test")
|
||||
fac.IO = io
|
||||
fac.IO.StdErr = stderr
|
||||
fac.IO.StdOut = stdout
|
||||
|
||||
tests := []struct {
|
||||
Name string
|
||||
Args string
|
||||
StdOut string
|
||||
WantErr error
|
||||
}{
|
||||
{
|
||||
Name: "with no path specified",
|
||||
Args: "",
|
||||
StdOut: "Validating...\n✓ CI/CD YAML is valid!\n",
|
||||
},
|
||||
{
|
||||
Name: "with path specified as url",
|
||||
Args: glTestHost + "/cli-automated-testing/test/-/raw/master/.gitlab-ci.yml",
|
||||
StdOut: "Validating...\n✓ CI/CD YAML is valid!\n",
|
||||
},
|
||||
}
|
||||
|
||||
cmd := NewCmdLint(fac)
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
_, err := cmdtest.RunCommand(cmd, test.Args)
|
||||
if err != nil {
|
||||
if test.WantErr == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, err, test.WantErr)
|
||||
}
|
||||
assert.Equal(t, test.StdOut, stdout.String())
|
||||
stdout.Reset()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ hosts:
|
|||
|
||||
var io *iostreams.IOStreams
|
||||
io, _, stdout, _ = iostreams.Test()
|
||||
stubFactory, _ = cmdtest.StubFactoryWithConfig(glTestHost + "/cli-automated-testing/test.git")
|
||||
stubFactory, _ = cmdtest.StubFactoryWithConfig(glTestHost + "/cli-automated-testing/test")
|
||||
stubFactory.IO = io
|
||||
stubFactory.IO.IsaTTY = true
|
||||
stubFactory.IO.IsErrTTY = true
|
||||
|
@ -111,7 +111,7 @@ func TestTraceRun(t *testing.T) {
|
|||
|
||||
var io *iostreams.IOStreams
|
||||
io, _, stdout, _ = iostreams.Test()
|
||||
stubFactory = cmdtest.StubFactory(glTestHost + "/cli-automated-testing/test.git")
|
||||
stubFactory = cmdtest.StubFactory(glTestHost + "/cli-automated-testing/test")
|
||||
stubFactory.IO = io
|
||||
stubFactory.IO.IsaTTY = true
|
||||
stubFactory.IO.IsErrTTY = true
|
||||
|
|
Loading…
Reference in New Issue