@@ -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
188187type 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 {
0 commit comments