Skip to content

Commit

Permalink
Merge pull request #15 from agrostar/curl-test
Browse files Browse the repository at this point in the history
introduce tests for the output of getCurlRequest, to ensure the output is valid for simple cases
  • Loading branch information
Varun0157 authored Jul 6, 2024
2 parents 7542632 + 40d112b commit 1377088
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 154 deletions.
1 change: 1 addition & 0 deletions docs/zzapi-bundle-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Operators supported in the RHS are:
* `$type`: string|number|object|array|null: to check the type of the field
* `$tests`: perform assertions (recursively) on the value, as if it were the `$.` root
* `$skip`: skip the assertions under this test. Useful in case some tests are failing, but we want the output to keep reminding us of this fact.
* `$multi`: use `jasonpath.query` (all matches) instead of `jasonpath.value` (first match) to evaluate the JSONPath expresson. This is useful if you need to evaluate multiple nested elements of an object array all at once.

### jsonpath tests

Expand Down
4 changes: 2 additions & 2 deletions examples/tests-bundle.zzb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ requests:
params:
foo1: bar1
foo2: bar2
tests: # old way of specifying json tests
tests:
json:
$.args.foo1: bar1
$.args.foo2: bar2
Expand All @@ -44,7 +44,7 @@ requests:
params:
foo1: bar1
foo2:
tests: # new way of specifying json
tests:
$.url: "https://postman-echo.com/get?foo1=bar1&foo2"

get-with-params-as-array:
Expand Down
5 changes: 3 additions & 2 deletions schemas/zzapi-bundle.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
"enum": ["number", "string", "boolean", "object", "array", "null", "undefined"]
},
"$regex": { "type": "string" },
"$options": { "type": "string" },
"$exists": { "type": "boolean" },
"$size": {
"anyOf": [
Expand All @@ -132,7 +131,9 @@
]
},
"$tests": { "$ref": "#/$defs/tests" },
"$skip": { "type": "boolean" }
"$options": { "type": "string" },
"$skip": { "type": "boolean" },
"$multi": { "type": "boolean" }
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/constructCurl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getStringValueIfDefined } from "./utils/typeUtils";

import { getParamsForUrl, getURL } from "./executeRequest";
import { RequestSpec } from "./models";
import { getParamsForUrl, getURL } from "./executeRequest";

function replaceSingleQuotes<T>(value: T): T {
if (typeof value !== "string") return value;
Expand Down
2 changes: 1 addition & 1 deletion src/replaceVars.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getStrictStringValue, isArrayOrDict } from "./utils/typeUtils";

import { Variables } from "./variables";
import { RequestSpec } from "./models";
import { Variables } from "./variables";

function replaceVariablesInArray(
data: any[],
Expand Down
Loading

0 comments on commit 1377088

Please sign in to comment.