forked from ivpusic/httpcheck
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtester_body_xml_test.go
59 lines (50 loc) · 1.07 KB
/
tester_body_xml_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
package httpcheck
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTester_WithXML(t *testing.T) {
mockT := new(testing.T)
checker := newTestChecker()
person := &testPerson{
Name: "Some",
Age: 30,
}
checker.Test(mockT, "GET", "/mirrorbody").
WithXML(person).
Check().
HasXML(person)
assert.False(t, mockT.Failed())
}
func TestTester_HasXML(t *testing.T) {
mockT := new(testing.T)
person := &testPerson{
Name: "Some",
Age: 30,
}
checker := newTestChecker()
result := checker.Test(mockT, "GET", "/xml").
Check().
HasXML(person)
assert.False(t, mockT.Failed())
person = &testPerson{
Name: "Unknown",
Age: 30,
}
result.HasXML(person)
assert.True(t, mockT.Failed())
}
func TestTester_MustHasXml(t *testing.T) {
t.Skip("skip this test because it expects failure.")
checker := newTestChecker()
checker.Test(t, "GET", "/xml").
Check().
MustHasXML(&testPerson{
Name: "Unknown",
Age: 30,
}).
Cb(func(response *http.Response) {
t.Fatal("it is expected that this assertion will not be executed.")
})
}