forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporter_test.go
65 lines (49 loc) · 1.19 KB
/
reporter_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package httpexpect
import (
"testing"
"github.com/stretchr/testify/assert"
)
type mockT struct {
testing.T
fatalfInvoked bool
}
func (m *mockT) Fatalf(format string, args ...interface{}) {
m.fatalfInvoked = true
}
type mockAssertT struct {
errorfInvoked bool
}
func (m *mockAssertT) Errorf(format string, args ...interface{}) {
m.errorfInvoked = true
}
type mockRequireT struct {
testing.T
failNowInvoked bool
}
func (m *mockRequireT) FailNow() {
m.failNowInvoked = true
}
func TestReporter_AssertReporter(t *testing.T) {
mockBackend := &mockAssertT{}
reporter := NewAssertReporter(mockBackend)
reporter.Errorf("test")
assert.True(t, mockBackend.errorfInvoked)
}
func TestReporter_RequireReporter(t *testing.T) {
mockBackend := &mockRequireT{}
reporter := NewRequireReporter(mockBackend)
reporter.Errorf("test")
assert.True(t, mockBackend.failNowInvoked)
}
func TestReporter_FatalReporter(t *testing.T) {
mockBackend := &mockT{}
reporter := NewFatalReporter(mockBackend)
reporter.Errorf("test")
assert.True(t, mockBackend.fatalfInvoked)
}
func TestReporter_PanicReporter(t *testing.T) {
reporter := NewPanicReporter()
assert.Panics(t, func() {
reporter.Errorf("test")
})
}