How to disable check_response by default #89
-
Before #80 (reply in thread) is solved, I need to disable
But got:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, yes this is something missing but the reason for that is how the check_response works. It is actually short version of assert_response element. So instead of: plan {
group {
http 'GET http://www.example.com', {
assert_response field: 'response_code', rule: 'equals', {
pattern '200'
}
assert_response field: 'response_code', rule: 'equals', {
pattern '204'
}
}
}
} You write: plan {
group {
http {
check_response {
status() eq 200
status() eq 204
}
}
}
} The check_response is container to several Response Assertion objects where each can be enabled, can have different name and comments. So, setting value on check_response would change value on all of them. OK. the solution for that I think would be to change the structure of check_response and remove 'not' stuff from status() and change some naming for keywords to better express what is going on. The following changes would apply: plan {
group {
check_response {
// current
status(not) eq 200
// new
status() ne 200
// no change
status() eq 210
// no change
status() substring '500' and '400'
// current
status() contains 'pattern \\d+'
// new
status() includes 'pattern \\d+'
// no change
status() matches 'pattern \\d+'
// current
headers(not) contains 'COOKIES', 'no cookies'
// new
headers() excludes 'COOKIES', 'no cookies'
// current
headers() contains 'COOKIES', 'has cookies'
// new
headers() includes 'COOKIES', 'has cookies'
// current
text(not) contains 'test text'
// new
text() excludes 'test text'
// current
text() contains 'test text'
// new
text() includes 'test text'
// current
document(not) contains 'some text'
// new
document() excludes 'some text'
// current
document() contains 'some text'
// new
document() includes 'some text'
// current
message(not) eq 'OK', 'Not OK'
// new
message() ne 'OK', 'Not OK'
// no change
message() eq 'OK', 'OK'
// current
url(not) contains 'localhost', 'external'
// new
url() excludes 'localhost', 'external'
// current
url() contains 'localhost', 'local'
// new
url() includes 'localhost', 'local'
// no change
duration() eq 2000
// no change
md5hex() eq '2bf7b8126bb7c645638e444f6e2c58a5'
}
}
} So in most cases contains/not contains is changed to includes/excludes pair. The eq/not eq change to eq/ne. Moreover the properties name, enabled, comments will be available for all keywords inside check_response, and also one enabled on check_response level to change or inner elements. E.g. plan {
group {
check_response enabled: true, {
// full version to change everything
status(name: 'Check Status', comments: 'Check Status', enabled: true) eq 200
// short version only name
status('Check Status') ne 200
// or only for enabled
status(enabled: false) eq 210
// normal usage
status() eq 302
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Fixed with #95 |
Beta Was this translation helpful? Give feedback.
Hi, yes this is something missing but the reason for that is how the check_response works. It is actually short version of assert_response element. So instead of:
You write:
The check_response is container to several Response Assertion objects where each can…