Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases to match with integers/floats #39

Merged
merged 2 commits into from
Aug 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions testcases/request/body/matches with floats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"match": true,
"comment": "Request matches with floats",
"expected": {
"headers": {"Content-Type": "application/json"},
"matchingRules": {
"$.body.alligator.feet": {"match": "regex", "regex": "\\d(\\.\\d{1,2})"}
Copy link
Member

Choose a reason for hiding this comment

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

$.body.alligator.feet does not match the body. Should it be $.body.product.price?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I forgot this :)

Thanks @uglyog.

},
"body": [
{
"product": {
"id": 123,
"description": "Television",
"price": 500.55
}
}
]
},
"actual": {
"headers": {"Content-Type": "application/json"},
"body": [
{
"product": {
"id": 123,
"description": "Television",
"price": 500.55
}
}
]
}
}
33 changes: 33 additions & 0 deletions testcases/request/body/matches with integers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"match": true,
"comment": "Request match with integers",
"expected" : {
"method": "POST",
"path": "/",
"query": "",
"headers": {"Content-Type": "application/json"},
"matchingRules": {
"$.body.alligator.feet": {"match": "regex", "regex": "[0-9]"}
},
"body": {
"alligator":{
"name": "Mary",
"feet": 4,
"favouriteColours": ["red","blue"]
}
}
},
"actual": {
"method": "POST",
"path": "/",
"query": "",
"headers": {"Content-Type": "application/json"},
"body": {
"alligator":{
"feet": 4,
"name": "Mary",
"favouriteColours": ["red","blue"]
}
}
}
}
31 changes: 31 additions & 0 deletions testcases/response/body/matches with floats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"match": true,
"comment": "Response match with floats",
"expected": {
"headers": {"Content-Type": "application/json"},
"matchingRules": {
"$.body.alligator.feet": {"match": "regex", "regex": "\\d(\\.\\d{1,2})"}
Copy link
Member

Choose a reason for hiding this comment

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

Same as per comment on request body.

},
"body": [
{
"product": {
"id": 123,
"description": "Television",
"price": 500.55
}
}
]
},
"actual": {
"headers": {"Content-Type": "application/json"},
"body": [
{
"product": {
"id": 123,
"description": "Television",
"price": 500.55
}
}
]
}
}
33 changes: 33 additions & 0 deletions testcases/response/body/matches with integers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"match": true,
"comment": "Response match with integers",
"expected" : {
"method": "POST",
"path": "/",
"query": "",
"headers": {"Content-Type": "application/json"},
"matchingRules": {
"$.body.alligator.feet": {"match": "regex", "regex": "[0-9]"}
},
"body": {
"alligator":{
"name": "Mary",
"feet": 4,
"favouriteColours": ["red","blue"]
}
}
},
"actual": {
"method": "POST",
"path": "/",
"query": "",
"headers": {"Content-Type": "application/json"},
"body": {
"alligator":{
"feet": 4,
"name": "Mary",
"favouriteColours": ["red","blue"]
}
}
}
}