-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic CLI test using Ginkgo/Gomega
Test that we can call our CLI binary with the `--help` flag and make some basic assertions about its output. I'll commit the new dependencies to `vendor/` in a separate commit to make the diff easier to read.
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main_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 TestCircleciCli(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "CircleciCli Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main_test | ||
|
||
import ( | ||
"os/exec" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("Main", func() { | ||
Describe("when run with --help", func() { | ||
It("return exit code 0 with help message", func() { | ||
command := exec.Command(pathCLI, "--help") | ||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
Eventually(session).Should(gexec.Exit(0)) | ||
Eventually(session.Out).Should(gbytes.Say("Usage:")) | ||
Eventually(session.Err.Contents()).Should(BeEmpty()) | ||
}) | ||
}) | ||
}) |