Skip to content

Commit

Permalink
Cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Jan 27, 2023
1 parent 4a67412 commit 43b0a86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions reporter.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package httpexpect

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -21,7 +20,7 @@ func NewAssertReporter(t assert.TestingT) *AssertReporter {

// Errorf implements Reporter.Errorf.
func (r *AssertReporter) Errorf(message string, args ...interface{}) {
r.backend.Fail(fmt.Sprintf(message, args...))
r.backend.Fail(message, args...)
}

// RequireReporter implements Reporter interface using `testify/require'
Expand All @@ -37,7 +36,7 @@ func NewRequireReporter(t require.TestingT) *RequireReporter {

// Errorf implements Reporter.Errorf.
func (r *RequireReporter) Errorf(message string, args ...interface{}) {
r.backend.FailNow(fmt.Sprintf(message, args...))
r.backend.FailNow(message, args...)
}

// FatalReporter is a struct that implements the Reporter interface
Expand All @@ -47,8 +46,8 @@ type FatalReporter struct {
}

// NewFatalReporter returns a new FatalReporter object.
func NewFatalReporter(backend testing.TB) *FatalReporter {
return &FatalReporter{backend}
func NewFatalReporter(t testing.TB) *FatalReporter {
return &FatalReporter{t}
}

// Errorf implements Reporter.Errorf.
Expand Down
4 changes: 2 additions & 2 deletions reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ func (m *mockT) Fatalf(format string, args ...interface{}) {
m.fatalfInvoked = true
}

func TestFatalReporter(t *testing.T) {
func TestReporter_FatalReporter(t *testing.T) {
mockBackend := &mockT{}
reporter := NewFatalReporter(mockBackend)

t.Run("Test Errorf", func(t *testing.T) {
t.Run("Errorf", func(t *testing.T) {
reporter.Errorf("Test failed with backend: %v", mockBackend)
assert.True(t, mockBackend.fatalfInvoked)
})
Expand Down

0 comments on commit 43b0a86

Please sign in to comment.