Skip to content
Merged
11 changes: 11 additions & 0 deletions contracts/testing/assertable_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ package testing

type AssertableJSON interface {
Json() map[string]any
Count(key string, value int) AssertableJSON
Has(key string) AssertableJSON
HasAll(keys []string) AssertableJSON
HasAny(keys []string) AssertableJSON
Missing(key string) AssertableJSON
MissingAll(keys []string) AssertableJSON
Where(key string, value any) AssertableJSON
WhereNot(key string, value any) AssertableJSON
Each(key string, callback func(AssertableJSON)) AssertableJSON
First(key string, callback func(AssertableJSON)) AssertableJSON
HasWithScope(key string, length int, callback func(AssertableJSON)) AssertableJSON
Comment on lines +13 to +15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort them and add test cases for them.

Copy link
Copy Markdown
Member Author

@krishankumar01 krishankumar01 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already added test cases. Plz find in assertable_json_test

}
10 changes: 7 additions & 3 deletions contracts/testing/test_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ import (
)

type TestRequest interface {
WithHeaders(headers map[string]string) TestRequest
WithHeader(key, value string) TestRequest
WithoutHeader(key string) TestRequest
FlushHeaders() TestRequest
WithCookies(cookies map[string]string) TestRequest
WithCookie(key, value string) TestRequest
WithContext(ctx context.Context) TestRequest
WithHeaders(headers map[string]string) TestRequest
WithHeader(key, value string) TestRequest
WithoutHeader(key string) TestRequest
WithToken(token string, ttype ...string) TestRequest
WithBasicAuth(username, password string) TestRequest
WithoutToken() TestRequest
Get(uri string) (TestResponse, error)
Post(uri string, body io.Reader) (TestResponse, error)
Put(uri string, body io.Reader) (TestResponse, error)
Expand Down
4 changes: 4 additions & 0 deletions contracts/testing/test_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ type TestResponse interface {
AssertDontSee([]string, ...bool) TestResponse
AssertSee([]string, ...bool) TestResponse
AssertSeeInOrder([]string, ...bool) TestResponse
AssertJson(map[string]any) TestResponse
AssertExactJson(map[string]any) TestResponse
AssertJsonMissing(map[string]any) TestResponse
AssertFluentJson(func(json AssertableJSON)) TestResponse
}
Loading