diff --git a/commands/ci/lint/lint_integration_test.go b/commands/ci/lint/lint_integration_test.go index 38d03c7892f4be7fc550d69619f52e2dd72a323c..4156473aea1b627848f233b5c67bccc804877517 100644 --- a/commands/ci/lint/lint_integration_test.go +++ b/commands/ci/lint/lint_integration_test.go @@ -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) - // - // 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() - // }) - // } + glTestHost := test.GetHostOrSkip(t) + + 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() + }) + } } diff --git a/commands/ci/trace/trace_integration_test.go b/commands/ci/trace/trace_integration_test.go index 8b3318a186a61121827094f671c83b109c1ed693..840fc2e50fcca106c8ac94756b36ad27cf111d34 100644 --- a/commands/ci/trace/trace_integration_test.go +++ b/commands/ci/trace/trace_integration_test.go @@ -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