1package integration_test
2
3import (
4	. "github.com/onsi/ginkgo"
5	. "github.com/onsi/gomega"
6	"github.com/onsi/gomega/gexec"
7)
8
9var _ = Describe("Suite Command Specs", func() {
10	var pathToTest string
11
12	BeforeEach(func() {
13		pathToTest = tmpPath("suite_command")
14		copyIn(fixturePath("suite_command_tests"), pathToTest, false)
15	})
16
17	It("Runs command after suite echoing out suite data, properly reporting suite name and passing status in successful command output", func() {
18		command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
19		expected := "THIS IS A [PASS] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
20		session := startGinkgo(pathToTest, command)
21		Eventually(session).Should(gexec.Exit(0))
22		output := string(session.Out.Contents())
23
24		Ω(output).Should(ContainSubstring("1 Passed"))
25		Ω(output).Should(ContainSubstring("0 Failed"))
26		Ω(output).Should(ContainSubstring("1 Pending"))
27		Ω(output).Should(ContainSubstring("0 Skipped"))
28		Ω(output).Should(ContainSubstring("Test Suite Passed"))
29		Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
30		Ω(output).Should(ContainSubstring(expected))
31	})
32
33	It("Runs command after suite reporting that command failed", func() {
34		command := "-afterSuiteHook=exit 1"
35		session := startGinkgo(pathToTest, command)
36		Eventually(session).Should(gexec.Exit(0))
37		output := string(session.Out.Contents())
38
39		Ω(output).Should(ContainSubstring("1 Passed"))
40		Ω(output).Should(ContainSubstring("0 Failed"))
41		Ω(output).Should(ContainSubstring("1 Pending"))
42		Ω(output).Should(ContainSubstring("0 Skipped"))
43		Ω(output).Should(ContainSubstring("Test Suite Passed"))
44		Ω(output).Should(ContainSubstring("Post-suite command failed:"))
45	})
46
47	It("Runs command after suite echoing out suite data, properly reporting suite name and failing status in successful command output", func() {
48		command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
49		expected := "THIS IS A [FAIL] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
50		session := startGinkgo(pathToTest, "-failOnPending=true", command)
51		Eventually(session).Should(gexec.Exit(1))
52		output := string(session.Out.Contents())
53
54		Ω(output).Should(ContainSubstring("1 Passed"))
55		Ω(output).Should(ContainSubstring("0 Failed"))
56		Ω(output).Should(ContainSubstring("1 Pending"))
57		Ω(output).Should(ContainSubstring("0 Skipped"))
58		Ω(output).Should(ContainSubstring("Test Suite Failed"))
59		Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
60		Ω(output).Should(ContainSubstring(expected))
61	})
62
63})
64