forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boolean_test.go
111 lines (79 loc) · 1.9 KB
/
boolean_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package httpexpect
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBooleanFailed(t *testing.T) {
chain := makeChain(newMockReporter(t))
chain.fail("fail")
value := &Boolean{chain, false}
value.chain.assertFailed(t)
value.Path("$").chain.assertFailed(t)
value.Schema("")
value.Equal(false)
value.NotEqual(false)
value.True()
value.False()
}
func TestBooleanGetters(t *testing.T) {
reporter := newMockReporter(t)
value := NewBoolean(reporter, true)
assert.Equal(t, true, value.Raw())
value.chain.assertOK(t)
value.chain.reset()
assert.Equal(t, true, value.Path("$").Raw())
value.chain.assertOK(t)
value.chain.reset()
value.Schema(`{"type": "boolean"}`)
value.chain.assertOK(t)
value.chain.reset()
value.Schema(`{"type": "object"}`)
value.chain.assertFailed(t)
value.chain.reset()
}
func TestBooleanTrue(t *testing.T) {
reporter := newMockReporter(t)
value := NewBoolean(reporter, true)
assert.Equal(t, true, value.Raw())
value.Equal(true)
value.chain.assertOK(t)
value.chain.reset()
value.Equal(false)
value.chain.assertFailed(t)
value.chain.reset()
value.NotEqual(false)
value.chain.assertOK(t)
value.chain.reset()
value.NotEqual(true)
value.chain.assertFailed(t)
value.chain.reset()
value.True()
value.chain.assertOK(t)
value.chain.reset()
value.False()
value.chain.assertFailed(t)
value.chain.reset()
}
func TestBooleanFalse(t *testing.T) {
reporter := newMockReporter(t)
value := NewBoolean(reporter, false)
assert.Equal(t, false, value.Raw())
value.Equal(true)
value.chain.assertFailed(t)
value.chain.reset()
value.Equal(false)
value.chain.assertOK(t)
value.chain.reset()
value.NotEqual(false)
value.chain.assertFailed(t)
value.chain.reset()
value.NotEqual(true)
value.chain.assertOK(t)
value.chain.reset()
value.True()
value.chain.assertFailed(t)
value.chain.reset()
value.False()
value.chain.assertOK(t)
value.chain.reset()
}