-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpect.go
More file actions
28 lines (24 loc) · 716 Bytes
/
expect.go
File metadata and controls
28 lines (24 loc) · 716 Bytes
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
package testpilot
type Expect struct {
expectedResponseCode *int
expectedResponseBody *AssertionFunc
headerAssertions map[string]func(string) error
}
// Status sets the expected response code
func (e *Expect) Status(code int) *Expect {
e.expectedResponseCode = &code
return e
}
// Body sets the expected response body
func (e *Expect) Body(assertionFunc AssertionFunc) *Expect {
e.expectedResponseBody = &assertionFunc
return e
}
// Header sets the expected response header
func (e *Expect) Header(key string, assertionFunc func(string) error) *Expect {
if e.headerAssertions == nil {
e.headerAssertions = make(map[string]func(string) error)
}
e.headerAssertions[key] = assertionFunc
return e
}