Skip to content

Commit

Permalink
Move existing integration test to cmd package
Browse files Browse the repository at this point in the history
So that we can organise the tests per sub-command/verb. The current
`--help` test belongs to functionality in `root.go`.

I've left the remaining contents of `circleci_cli_suite_test.go` so that
you can run `ginkgo -r` from the root of the repo. The `main` package
should be so simple that we don't need any specs there though.
  • Loading branch information
dcarley committed Jun 13, 2018
1 parent e518c58 commit 6760da2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
13 changes: 0 additions & 13 deletions circleci_cli_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,8 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)

var pathCLI string

var _ = BeforeSuite(func() {
var err error
pathCLI, err = gexec.Build("github.com/circleci/circleci-cli")
Ω(err).ShouldNot(HaveOccurred())
})

var _ = AfterSuite(func() {
gexec.CleanupBuildArtifacts()
})

func TestCircleciCli(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "CircleciCli Suite")
Expand Down
26 changes: 26 additions & 0 deletions cmd/cmd_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)

var pathCLI string

var _ = BeforeSuite(func() {
var err error
pathCLI, err = gexec.Build("github.com/circleci/circleci-cli")
Ω(err).ShouldNot(HaveOccurred())
})

var _ = AfterSuite(func() {
gexec.CleanupBuildArtifacts()
})

func TestCmd(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Cmd Suite")
}
4 changes: 2 additions & 2 deletions main_test.go → cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main_test
package cmd_test

import (
"os/exec"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/onsi/gomega/gexec"
)

var _ = Describe("Main", func() {
var _ = Describe("Root", func() {
Describe("when run with --help", func() {
It("return exit code 0 with help message", func() {
command := exec.Command(pathCLI, "--help")
Expand Down

0 comments on commit 6760da2

Please sign in to comment.