Skip to content

Commit

Permalink
Merge pull request #3 from adamyonk/check_var_interpolation
Browse files Browse the repository at this point in the history
Check variable interpolation
  • Loading branch information
Matthew R. Miller authored Oct 29, 2018
2 parents 0fbb04d + 65f661e commit 142ce45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ checks:
- name: Proper body for updated username
check: response.body.json.username
value: "{{cache.body.username}}"
- name: Has fav ID
check: response.body.json.favs.#[id=="{{cache.body.fav_id}}"].id
value: "{{cache.body.fav_id}}"
```
- name: Defines the name of your test.
- url: Defines the URL to use in the test. This may make use of [variables](#variables).
Expand Down Expand Up @@ -142,7 +145,7 @@ Test checks are used to validate results of the test.
- name: Defines the name of your test. Can be any string.
- check: Defines the check to use. Can be any of the following:
- response.code: References response HTTP status code.
- response.body.json: Refers the json body of the response. Anything following this prefix this will [query methods of the json](#json-query) body.
- response.body.json: Refers the json body of the response. Anything following this prefix will [query methods of the json](#json-query) body, and may make use of [variables](#variables).
- value: Defines the value to use in the test. This may make use of [variables](#variables).
## Variables
Expand Down
1 change: 1 addition & 0 deletions manatest/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func RunChecks(checks *[]TestChecks, vars *[]ProjectGlobal, response *resty.Resp
for _, check := range *checks {

// Replace variables
check.Check = ReplaceVarsInCheck(check.Check, vars)
check.Value = ReplaceVarsInCheck(check.Value, vars)

// Check response code
Expand Down
2 changes: 2 additions & 0 deletions manatest/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestValidateCheck(tst *testing.T) {
checks := []string{
"response.code",
"response.body.json",
"response.body.json.{{cache.something}}",
}
for _, check := range checks {
valid := ValidateCheck(&check)
Expand All @@ -26,6 +27,7 @@ func TestValidateCheck(tst *testing.T) {
"1323423423",
"FLKDKDKS@",
"ddddsdfsd",
"response.{{cache.something}}.json",
}
for _, check := range checks {
valid := ValidateCheck(&check)
Expand Down

0 comments on commit 142ce45

Please sign in to comment.