You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.MD
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ This project **cuts initial time** & allows bootstrap e2e test framework with **
12
12
utility methods** in just few steps. Just grab it and write tests right away!
13
13
14
14
Benefits:
15
-
*[35+ well-documented, coupled in logical groups steps](https://github.com/pawelWritesCode/godog-http-api/wiki/Steps) useful for testing HTTP(s) API,
15
+
*[40+ well-documented, coupled in logical groups steps](https://github.com/pawelWritesCode/godog-http-api/wiki/Steps) useful for testing HTTP(s) API,
16
16
* support for using templated values as in [text/template](https://pkg.go.dev/text/template) package,
17
-
* support for querying nodes with different path engines ([oliveagle](https://github.com/oliveagle/jsonpath), [qjson](https://github.com/pawelWritesCode/qjson) - JSON, [go-yaml](https://github.com/goccy/go-yaml) - YAML, [antchfx](https://github.com/antchfx/xmlquery) - XML),
17
+
* support for querying nodes with different path engines ([oliveagle](https://github.com/oliveagle/jsonpath), [gjson](https://github.com/tidwall/gjson) - JSON, [go-yaml](https://github.com/goccy/go-yaml) - YAML, [antchfx](https://github.com/antchfx/xmlquery) - XML),
18
18
* support for sending _multipart/form-data_ forms with file in it,
19
19
* developed with debugging in mind,
20
20
* customisable through ability to [replace](https://github.com/pawelWritesCode/godog-http-api/blob/main/main_test.go#L53) utility services with your own implementations,
@@ -41,7 +41,7 @@ Feature: Adding new user
41
41
Given I generate a random word having from "5" to "10" of "ASCII" characters and save it as "RANDOM_FIRST_NAME"
42
42
Given I generate a random word having from "3" to "7" of "UNICODE" characters and save it as "RANDOM_LAST_NAME"
43
43
Given I generate a random sentence having from "3" to "4" of "english" words and save it as "RANDOM_DESCRIPTION"
44
-
Given I generate a random "int" in the range from "18" to "48" and save it as "RANDOM_AGE"
44
+
Given I generate a random "int" in the range from "18" to "20" and save it as "RANDOM_AGE"
45
45
Given I generate current time and travel "backward" "240h" in time and save it as "MEET_DATE"
46
46
Given I save "application/json" as "CONTENT_TYPE_JSON"
47
47
@@ -77,21 +77,19 @@ Feature: Adding new user
77
77
But the response body should have format "JSON"
78
78
And time between last request and response should be less than or equal to "2s"
79
79
80
-
# uncommenting next line will print last HTTP(s) response body to console
80
+
# uncommenting next line will print data to console
81
81
# Given I print last response body
82
+
# Given I print cache data
82
83
83
84
# This waiting is unnecessary, just added for demonstration
# We validate response body with schema from assets/test_server/doc/schema/user/user.json
88
-
# step argument may be: relative (see .env variable GODOG_JSON_SCHEMA_DIR)
89
+
# step argument may be: relative (see .env variable GODOG_JSON_SCHEMA_DIR), full OS path, URL or raw schema definition
89
90
And the response body should be valid according to schema "user/user.json"
90
-
# or full OS path
91
91
And the response body should be valid according to schema "{{.CWD}}/assets/test_server/doc/schema/user/user.json"
92
-
# or URL pointing at schema
93
92
And the response body should be valid according to schema "https://raw.githubusercontent.com/pawelWritesCode/godog-http-api/main/assets/test_server/doc/schema/user/user.json"
94
-
# or raw schema definition passed in Docstring
95
93
And the response body should be valid according to schema:
96
94
"""
97
95
{
@@ -110,17 +108,28 @@ Feature: Adding new user
110
108
"type": "string"
111
109
}
112
110
"""
113
-
# here is used qjson "json-path" syntax to find JSON node
111
+
# here are used two different json-path engines (gjson & oliveagle) to find JSON nodes
114
112
And the "JSON" node "firstName" should be "string" of value "{{.RANDOM_FIRST_NAME}}"
115
-
# here is used oliveagle "json-path" syntax to find JSON node
116
113
And the "JSON" node "$.lastName" should be "string" of value "doe-{{.RANDOM_LAST_NAME}}"
114
+
115
+
# here we look for substrings
116
+
And the "JSON" node "$.lastName" should not contain sub string "smith"
117
+
But the "JSON" node "$.lastName" should contain sub string "doe"
118
+
117
119
# here is used regExp acceptable by standard go package "regExp"
118
120
And the "JSON" node "lastName" should not match regExp "smith-.*"
119
121
But the "JSON" node "lastName" should match regExp "doe-.*"
122
+
123
+
# assertion may be based on one of JSON data types: array, boolean, null, number, object
120
124
And the "JSON" node "age" should not be "string"
125
+
But the "JSON" node "$.age" should be "number"
126
+
And the "JSON" node "$.age" should be "number" and contain one of values "18, 19, 20"
127
+
128
+
# or on one of Go-like data types: bool, float, int, map, slice, string
121
129
But the "JSON" node "$.age" should be "int"
122
130
And the "JSON" node "age" should be "int" of value "{{.RANDOM_AGE}}"
123
131
And the "JSON" node "description" should be "string" of value "{{.RANDOM_DESCRIPTION}}"
132
+
124
133
# here date is formatted according to one of available formats from standard go package "time"
125
134
And the "JSON" node "friendSince" should be "string" of value "{{.MEET_DATE.Format `2006-01-02T15:04:05Z`}}"
# We validate response body with schema from assets/test_server/doc/schema/user/user.json
61
-
# step argument may be: relative (see .env variable GODOG_JSON_SCHEMA_DIR)
62
+
# step argument may be: relative (see .env variable GODOG_JSON_SCHEMA_DIR), full OS path, URL or raw schema definition
62
63
And the response body should be valid according to schema "user/user.json"
63
-
# or full OS path
64
64
And the response body should be valid according to schema "{{.CWD}}/assets/test_server/doc/schema/user/user.json"
65
-
# or URL pointing at schema
66
65
And the response body should be valid according to schema "https://raw.githubusercontent.com/pawelWritesCode/godog-http-api/main/assets/test_server/doc/schema/user/user.json"
67
-
# or raw schema definition passed in Docstring
68
66
And the response body should be valid according to schema:
69
67
"""
70
68
{
@@ -83,17 +81,28 @@ Feature: Adding new user
83
81
"type": "string"
84
82
}
85
83
"""
86
-
# here is used qjson "json-path" syntax to find JSON node
84
+
# here are used two different json-path engines (gjson & oliveagle) to find JSON nodes
87
85
And the "JSON" node "firstName" should be "string" of value "{{.RANDOM_FIRST_NAME}}"
88
-
# here is used oliveagle "json-path" syntax to find JSON node
89
86
And the "JSON" node "$.lastName" should be "string" of value "doe-{{.RANDOM_LAST_NAME}}"
87
+
88
+
# here we look for substrings
89
+
And the "JSON" node "$.lastName" should not contain sub string "smith"
90
+
But the "JSON" node "$.lastName" should contain sub string "doe"
91
+
90
92
# here is used regExp acceptable by standard go package "regExp"
91
93
And the "JSON" node "lastName" should not match regExp "smith-.*"
92
94
But the "JSON" node "lastName" should match regExp "doe-.*"
95
+
96
+
# assertion may be based on one of JSON data types: array, boolean, null, number, object
93
97
And the "JSON" node "age" should not be "string"
98
+
But the "JSON" node "$.age" should be "number"
99
+
And the "JSON" node "$.age" should be "number" and contain one of values "18, 19, 20"
100
+
101
+
# or on one of Go-like data types: bool, float, int, map, slice, string
94
102
But the "JSON" node "$.age" should be "int"
95
103
And the "JSON" node "age" should be "int" of value "{{.RANDOM_AGE}}"
96
104
And the "JSON" node "description" should be "string" of value "{{.RANDOM_DESCRIPTION}}"
105
+
97
106
# here date is formatted according to one of available formats from standard go package "time"
98
107
And the "JSON" node "friendSince" should be "string" of value "{{.MEET_DATE.Format `2006-01-02T15:04:05Z`}}"
0 commit comments