Skip to content

Commit

Permalink
remove mockable exit var as it is no longer needed
Browse files Browse the repository at this point in the history
Signed-off-by: jesus m. rodriguez <jmrodri@gmail.com>
  • Loading branch information
jmrodri committed Apr 18, 2022
1 parent cf3e292 commit 89cd7e3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
3 changes: 0 additions & 3 deletions pkg/validate/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ func (r *Result) prepare() error {
return nil
}

// Mockable exit function for tests.
var exit = os.Exit

// PrintWithFormat prints output to w in format, and exits if some object in output
// is not in a passing state.
func (r *Result) PrintWithFormat(format string) (failed bool, err error) {
Expand Down
9 changes: 0 additions & 9 deletions pkg/validate/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,10 @@ var _ = Describe("Output Result", func() {
var w *bytes.Buffer
var output []byte
var resJSON Result
var exitCode int
exit = func(code int) {
exitCode = code
}
const warnText = "example of a warning"
const errorText = "example of an error"

BeforeEach(func() {
exitCode = 0
w = &bytes.Buffer{}
resJSON = Result{}
})
Expand All @@ -177,7 +172,6 @@ var _ = Describe("Output Result", func() {
Expect(resJSON.Outputs).To(HaveLen(1))
Expect(resJSON.Outputs[0].Type).To(Equal("warning"))
Expect(resJSON.Outputs[0].Message).To(Equal(warnText))
Expect(exitCode).To(Equal(0))
})

It("prints an error", func() {
Expand All @@ -193,7 +187,6 @@ var _ = Describe("Output Result", func() {
Expect(resJSON.Outputs).To(HaveLen(1))
Expect(resJSON.Outputs[0].Type).To(Equal("error"))
Expect(resJSON.Outputs[0].Message).To(Equal(errorText))
Expect(exitCode).To(Equal(0))
})
})

Expand All @@ -209,7 +202,6 @@ var _ = Describe("Output Result", func() {
line := string(lines[0])
Expect(line).To(ContainSubstring("level=warning"), line)
Expect(line).To(ContainSubstring(`msg="example of a warning"`), line)
Expect(exitCode).To(Equal(0))
})

It("prints an error", func() {
Expand All @@ -224,7 +216,6 @@ var _ = Describe("Output Result", func() {
fmt.Println(line)
Expect(line).To(ContainSubstring("level=error"), line)
Expect(line).To(ContainSubstring(`msg="example of an error"`), line)
Expect(exitCode).To(Equal(0))
})
})

Expand Down

0 comments on commit 89cd7e3

Please sign in to comment.