-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Bump to ginkgo v2 and seperate color / no color tests into their own suites** - this is because you need to pass new reporter config to run specs - I don't like this because the seperation seems arbitrary without knowing how ginkgo v2 wants things setup - kept the tests nested in command reporter to at least kinda keep the suites together Authored-by: Michael Oleske <moleske@pivotal.io>
- Loading branch information
Showing
47 changed files
with
172 additions
and
115 deletions.
There are no files selected for viewing
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
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
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,37 @@ | ||
package commandreporter_color_test | ||
|
||
import ( | ||
"os/exec" | ||
"time" | ||
|
||
"github.com/cloudfoundry/cf-test-helpers/commandreporter" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
) | ||
|
||
var _ = Describe("CommandReporter", func() { | ||
Describe("#Report", func() { | ||
var reporter *commandreporter.CommandReporter | ||
var writer *gbytes.Buffer | ||
var t time.Time | ||
var timestampRegex string | ||
BeforeEach(func() { | ||
writer = gbytes.NewBuffer() | ||
reporter = commandreporter.NewCommandReporter(writer) | ||
t = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) | ||
timestampRegex = "\\[2009-11-10 23:00:00.00 \\(UTC\\)\\]>" | ||
}) | ||
|
||
It("prints the timestamp and command in green", func() { | ||
cmd := exec.Command("executable", "arg1", "arg2") | ||
reporter.Report(t, cmd) | ||
|
||
lineStart := "^\n" | ||
greenStart := "\\x1b\\[32m" | ||
greenEnd := "\\x1b\\[0m" | ||
lineEnd := "\n$" | ||
Expect(writer).To(gbytes.Say("%s%s%s executable arg1 arg2 %s%s", lineStart, greenStart, timestampRegex, greenEnd, lineEnd)) | ||
}) | ||
}) | ||
}) |
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,15 @@ | ||
package commandreporter_color_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestCommandReporter(t *testing.T) { | ||
_, reportConfiguration := GinkgoConfiguration() | ||
reportConfiguration.NoColor = false | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Command Reporter Color Suite", reportConfiguration) | ||
} |
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
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
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
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,37 @@ | ||
package commandreporter_no_color_test | ||
|
||
import ( | ||
"os/exec" | ||
"time" | ||
|
||
"github.com/cloudfoundry/cf-test-helpers/commandreporter" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
) | ||
|
||
var _ = Describe("CommandReporter", func() { | ||
Describe("#Report", func() { | ||
var reporter *commandreporter.CommandReporter | ||
var writer *gbytes.Buffer | ||
var t time.Time | ||
var timestampRegex string | ||
BeforeEach(func() { | ||
writer = gbytes.NewBuffer() | ||
reporter = commandreporter.NewCommandReporter(writer) | ||
t = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) | ||
timestampRegex = "\\[2009-11-10 23:00:00.00 \\(UTC\\)\\]>" | ||
}) | ||
|
||
Context("when NoColor is specified", func() { | ||
It("does not print color", func() { | ||
cmd := exec.Command("executable", "arg1", "arg2") | ||
reporter.Report(t, cmd) | ||
|
||
lineStart := "^\n" | ||
lineEnd := "\n$" | ||
Expect(writer).To(gbytes.Say("%s%s executable arg1 arg2 %s", lineStart, timestampRegex, lineEnd)) | ||
}) | ||
}) | ||
}) | ||
}) |
15 changes: 15 additions & 0 deletions
15
commandreporter/nocolor/commandreporter_no_color_suite_test.go
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,15 @@ | ||
package commandreporter_no_color_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"testing" | ||
) | ||
|
||
func TestCommandReporter(t *testing.T) { | ||
_, reportConfiguration := GinkgoConfiguration() | ||
reportConfiguration.NoColor = true | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Command Reporter No Color Suite", reportConfiguration) | ||
} |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.