Skip to content

Commit

Permalink
separated out negative schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
vasan-agrostar committed Jun 30, 2024
1 parent 0fa5d50 commit 325eecc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
23 changes: 23 additions & 0 deletions tests/bundles/auto-negative-schema.zzb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
common:
baseUrl: https://postman-echo.com
headers:
Content-type: application/json

requests:
# This request tests should all fail due to bad tests schema
# Ensure we don't crash on these.
tests-negative-schema:
method: POST
url: /post
body:
address: 1, example street
numbers: [444, 222]
object: { foo: bar }
tests:
status: { $ne: 200 }
headers:
content-type: { $exists: false }
$.data.operator: { badop: any } # invalid operator badop. If you want to match an entire object/array, use it as the value of the $eq operator.
$.data.numbers: [444, 222]
$.data.address: { $type: invalid }
$.data.object: { $exists: 4 }
18 changes: 0 additions & 18 deletions tests/bundles/auto-tests.zzb
Original file line number Diff line number Diff line change
Expand Up @@ -298,24 +298,6 @@ requests:
$.data.age.something: 55 # jsonpath should take care of this.
$.data.numbers[5]: 0 # jsonpath should take care of this

# This request tests should all fail due to bad tests schema
# Ensure we don't crash on these.
tests-negative-schema:
method: POST
url: /post
body:
address: 1, example street
numbers: [444, 222]
object: { foo: bar }
tests:
status: { $ne: 200 }
headers:
content-type: { $exists: false }
$.data.operator: { badop: any } # invalid operator badop. If you want to match an entire object/array, use it as the value of the $eq operator.
$.data.numbers: [444, 222]
$.data.address: { $type: invalid }
$.data.object: { $exists: 4 }

capture-response-positive:
method: POST
url: /post
Expand Down
5 changes: 5 additions & 0 deletions tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ test("execute auto-tests.zzb in default env", async () => {
const rawReq = new RawRequest("./tests/bundles/auto-tests.zzb", "default");
expect(await callRequests(rawReq)).toBe(0);
});

test("execute auto-negative-schema.zzb in default env", async () => {
const rawReq = new RawRequest("./tests/bundles/auto-negative-schema.zzb", "default");
expect(await callRequests(rawReq)).toBe(0);
});

0 comments on commit 325eecc

Please sign in to comment.