forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chain_test.go
64 lines (42 loc) · 1.06 KB
/
chain_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
package httpexpect
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestChainFail(t *testing.T) {
chain := makeChain(newMockReporter(t))
assert.False(t, chain.failed())
chain.fail("fail")
assert.True(t, chain.failed())
chain.fail("fail")
assert.True(t, chain.failed())
}
func TestChainCopy(t *testing.T) {
chain1 := makeChain(newMockReporter(t))
chain2 := chain1
assert.False(t, chain1.failed())
assert.False(t, chain2.failed())
chain1.fail("fail")
assert.True(t, chain1.failed())
assert.False(t, chain2.failed())
chain2.fail("fail")
assert.True(t, chain1.failed())
assert.True(t, chain2.failed())
}
func TestChainReport(t *testing.T) {
r0 := newMockReporter(t)
chain := makeChain(r0)
r1 := newMockReporter(t)
chain.assertOK(r1)
assert.False(t, r1.reported)
chain.assertFailed(r1)
assert.True(t, r1.reported)
assert.False(t, chain.failed())
chain.fail("fail")
assert.True(t, r0.reported)
r2 := newMockReporter(t)
chain.assertFailed(r2)
assert.False(t, r2.reported)
chain.assertOK(r2)
assert.True(t, r2.reported)
}