Skip to content

Commit 49f06f7

Browse files
author
Stein Fletcher
committed
Bump apitest version
1 parent bc1a295 commit 49f06f7

File tree

4 files changed

+20
-33
lines changed

4 files changed

+20
-33
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ go 1.13
44

55
require (
66
github.com/PaesslerAG/jsonpath v0.1.1
7-
github.com/steinfletcher/apitest v1.5.3
7+
github.com/steinfletcher/apitest v1.5.10
88
github.com/stretchr/testify v1.7.0
99
)

go.sum

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,15 @@ github.com/PaesslerAG/jsonpath v0.1.1 h1:c1/AToHQMVsduPAa4Vh6xp2U0evy4t8SWp8imEs
66
github.com/PaesslerAG/jsonpath v0.1.1/go.mod h1:lVboNxFGal/VwW6d9JzIy56bUsYAP6tH/x80vjnCseY=
77
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
88
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
910
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1011
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1112
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12-
github.com/steinfletcher/apitest v1.4.8 h1:9SDVm1MCv6FRCd8xuGgoZA0TCsunN0TrXBon+ZL86wE=
13-
github.com/steinfletcher/apitest v1.4.8/go.mod h1:3nIZfM9GDQWGP9UGx6Zxk+LXc0DZFcZvy6+LfdhZa6U=
14-
github.com/steinfletcher/apitest v1.4.9 h1:8X7G+1m+GngIo5LFfDM0CxLSG9jcJn9LLeDH/Ov144M=
15-
github.com/steinfletcher/apitest v1.4.9/go.mod h1:0MT98QwexQVvf5pIn3fqiC/+8Nyd7A4RShxuSjnpOcE=
16-
github.com/steinfletcher/apitest v1.4.10 h1:uQ79AiO3U1hIM829m8p7ke0NsybrBaTLzv23gsHqjzQ=
17-
github.com/steinfletcher/apitest v1.4.10/go.mod h1:0MT98QwexQVvf5pIn3fqiC/+8Nyd7A4RShxuSjnpOcE=
18-
github.com/steinfletcher/apitest v1.4.11 h1:OsMXiVeIJs5kW5+SvF5fXJuQ4DQqgrDmcQxs4R4gZyg=
19-
github.com/steinfletcher/apitest v1.4.11/go.mod h1:0MT98QwexQVvf5pIn3fqiC/+8Nyd7A4RShxuSjnpOcE=
20-
github.com/steinfletcher/apitest v1.4.15/go.mod h1:0MT98QwexQVvf5pIn3fqiC/+8Nyd7A4RShxuSjnpOcE=
21-
github.com/steinfletcher/apitest v1.5.3/go.mod h1:TrZemFOZ1yNgKoAeAsth3Z3vEavTloE1hP/U2PSd3w0=
13+
github.com/steinfletcher/apitest v1.5.10 h1:uxEm/boegmZI9csm1fLVywB5b07ijcrcHo3PZO6sfns=
14+
github.com/steinfletcher/apitest v1.5.10/go.mod h1:cf7Bneo52IIAgpqhP8xaLlzWgAiQ9fHtsDMjeDnZ3so=
2215
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
2316
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
24-
github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho=
25-
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
26-
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
27-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
17+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
2818
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2919
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3020
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

jsonpath.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ import (
1414
"strings"
1515

1616
"github.com/PaesslerAG/jsonpath"
17-
"github.com/steinfletcher/apitest"
1817
)
1918

2019
// Contains is a convenience function to assert that a jsonpath expression extracts a value in an array
21-
func Contains(expression string, expected interface{}) apitest.Assert {
20+
func Contains(expression string, expected interface{}) func(*http.Response, *http.Request) error {
2221
return func(res *http.Response, req *http.Request) error {
2322
value, err := jsonPath(res.Body, expression)
2423
if err != nil {
@@ -37,7 +36,7 @@ func Contains(expression string, expected interface{}) apitest.Assert {
3736
}
3837

3938
// Equal is a convenience function to assert that a jsonpath expression extracts a value
40-
func Equal(expression string, expected interface{}) apitest.Assert {
39+
func Equal(expression string, expected interface{}) func(*http.Response, *http.Request) error {
4140
return func(res *http.Response, req *http.Request) error {
4241
value, err := jsonPath(res.Body, expression)
4342
if err != nil {
@@ -52,7 +51,7 @@ func Equal(expression string, expected interface{}) apitest.Assert {
5251
}
5352

5453
// NotEqual is a function to check json path expression value is not equal to given value
55-
func NotEqual(expression string, expected interface{}) apitest.Assert {
54+
func NotEqual(expression string, expected interface{}) func(*http.Response, *http.Request) error {
5655
return func(res *http.Response, req *http.Request) error {
5756
value, err := jsonPath(res.Body, expression)
5857
if err != nil {
@@ -67,7 +66,7 @@ func NotEqual(expression string, expected interface{}) apitest.Assert {
6766
}
6867

6968
// Len asserts that value is the expected length, determined by reflect.Len
70-
func Len(expression string, expectedLength int) apitest.Assert {
69+
func Len(expression string, expectedLength int) func(*http.Response, *http.Request) error {
7170
return func(res *http.Response, req *http.Request) error {
7271
value, err := jsonPath(res.Body, expression)
7372
if err != nil {
@@ -83,7 +82,7 @@ func Len(expression string, expectedLength int) apitest.Assert {
8382
}
8483

8584
// GreaterThan asserts that value is greater than the given length, determined by reflect.Len
86-
func GreaterThan(expression string, minimumLength int) apitest.Assert {
85+
func GreaterThan(expression string, minimumLength int) func(*http.Response, *http.Request) error {
8786
return func(res *http.Response, req *http.Request) error {
8887
value, err := jsonPath(res.Body, expression)
8988
if err != nil {
@@ -99,7 +98,7 @@ func GreaterThan(expression string, minimumLength int) apitest.Assert {
9998
}
10099

101100
// LessThan asserts that value is less than the given length, determined by reflect.Len
102-
func LessThan(expression string, maximumLength int) apitest.Assert {
101+
func LessThan(expression string, maximumLength int) func(*http.Response, *http.Request) error {
103102
return func(res *http.Response, req *http.Request) error {
104103
value, err := jsonPath(res.Body, expression)
105104
if err != nil {
@@ -115,7 +114,7 @@ func LessThan(expression string, maximumLength int) apitest.Assert {
115114
}
116115

117116
// Present asserts that value returned by the expression is present
118-
func Present(expression string) apitest.Assert {
117+
func Present(expression string) func(*http.Response, *http.Request) error {
119118
return func(res *http.Response, req *http.Request) error {
120119
value, _ := jsonPath(res.Body, expression)
121120
if isEmpty(value) {
@@ -126,7 +125,7 @@ func Present(expression string) apitest.Assert {
126125
}
127126

128127
// NotPresent asserts that value returned by the expression is not present
129-
func NotPresent(expression string) apitest.Assert {
128+
func NotPresent(expression string) func(*http.Response, *http.Request) error {
130129
return func(res *http.Response, req *http.Request) error {
131130
value, _ := jsonPath(res.Body, expression)
132131
if !isEmpty(value) {
@@ -137,7 +136,7 @@ func NotPresent(expression string) apitest.Assert {
137136
}
138137

139138
// Matches asserts that the value matches the given regular expression
140-
func Matches(expression string, regexp string) apitest.Assert {
139+
func Matches(expression string, regexp string) func(*http.Response, *http.Request) error {
141140
return func(res *http.Response, req *http.Request) error {
142141
pattern, err := regex.Compile(regexp)
143142
if err != nil {
@@ -187,7 +186,7 @@ func Root(expression string) *AssertionChain {
187186
// AssertionChain supports chaining assertions and root expressions
188187
type AssertionChain struct {
189188
rootExpression string
190-
assertions []apitest.Assert
189+
assertions []func(*http.Response, *http.Request) error
191190
}
192191

193192
// Equal adds an Equal assertion to the chain
@@ -226,8 +225,8 @@ func (r *AssertionChain) Matches(expression, regexp string) *AssertionChain {
226225
return r
227226
}
228227

229-
// End returns an apitest.Assert which is a combination of the registered assertions
230-
func (r *AssertionChain) End() apitest.Assert {
228+
// End returns an func(*http.Response, *http.Request) error which is a combination of the registered assertions
229+
func (r *AssertionChain) End() func(*http.Response, *http.Request) error {
231230
return func(res *http.Response, req *http.Request) error {
232231
for _, assertion := range r.assertions {
233232
if err := assertion(copyHttpResponse(res), copyHttpRequest(req)); err != nil {

jwt.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,22 @@ import (
77
"fmt"
88
"net/http"
99
"strings"
10-
11-
"github.com/steinfletcher/apitest"
1210
)
1311

1412
const (
1513
jwtHeaderIndex = 0
1614
jwtPayloadIndex = 1
1715
)
1816

19-
func JWTHeaderEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) apitest.Assert {
17+
func JWTHeaderEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) func(*http.Response, *http.Request) error {
2018
return jwtEqual(tokenSelector, expression, expected, jwtHeaderIndex)
2119
}
2220

23-
func JWTPayloadEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) apitest.Assert {
21+
func JWTPayloadEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}) func(*http.Response, *http.Request) error {
2422
return jwtEqual(tokenSelector, expression, expected, jwtPayloadIndex)
2523
}
2624

27-
func jwtEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}, index int) apitest.Assert {
25+
func jwtEqual(tokenSelector func(*http.Response) (string, error), expression string, expected interface{}, index int) func(*http.Response, *http.Request) error {
2826
return func(response *http.Response, request *http.Request) error {
2927
token, err := tokenSelector(response)
3028
if err != nil {

0 commit comments

Comments
 (0)