Last active
February 14, 2019 17:25
-
-
Save williammartin/e91535862687a331b534570d014e35d5 to your computer and use it in GitHub Desktop.
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
package acceptance_test | |
import ( | |
"os/exec" | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/gomega" | |
"github.com/onsi/gomega/gbytes" | |
"github.com/onsi/gomega/gexec" | |
) | |
var _ = Describe("Scratchpad", func() { | |
var session *gexec.Session | |
BeforeEach(func() { | |
scratchpadPath := buildScratchpad() | |
session = runScratchpad(scratchpadPath) | |
}) | |
AfterEach(func() { | |
gexec.CleanupBuildArtifacts() | |
}) | |
It("exits with status code 0", func() { | |
Eventually(session).Should(gexec.Exit(0)) | |
}) | |
It("prints 'Hello World' to stdout", func() { | |
Eventually(session).Should(gbytes.Say("Hello World")) | |
}) | |
}) | |
func buildScratchpad() string { | |
scratchpadPath, err := gexec.Build("github.com/williammartin/scratchpad") | |
Expect(err).NotTo(HaveOccurred()) | |
return scratchpadPath | |
} | |
func runScratchpad(path string) *gexec.Session { | |
cmd := exec.Command(path) | |
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) | |
Expect(err).NotTo(HaveOccurred()) | |
return session | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment