Skip to content

Commit

Permalink
1.0.2 release (#57)
Browse files Browse the repository at this point in the history
* update dependencies

* run portman overrides before variations tests

* update changelog

* do not include nested folders when performing orderOfOperations

* update changelog

* use collectionVariables not environment

* revert manipulation ordering in changelog

* variation target with openApiResponse code (#55)

* Added "variationTests" targeting for openApiResponse code

* Added unit tests for the variations with "openApiResponse" target

* Updated example

* extend getting and setting by path

* statusCode response default (#58)

* Provided support for StatusCode tests based on the variation?.openApiResponse

* Provided support for StatusCode tests based on the variation?.openApiResponse

* Added unit tests

* Provided support for StatusCode tests based on the variation?.openApiResponse

* Corrected typo's

* Clean-up unused tests

* Updated readme

Co-authored-by: thim81 <[email protected]>
  • Loading branch information
nicklloyd and thim81 authored Jun 22, 2021
1 parent c1695be commit d56a793
Show file tree
Hide file tree
Showing 23 changed files with 42,927 additions and 1,122 deletions.
21 changes: 19 additions & 2 deletions CHANEGLOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
## v1.0.2 - (2021-06-21)

### Bug Fixes

- contentTests that check against variables should use collectionVariables instead of environment variables

### Variation Tests

- nested folders (including variation tests) will be ignored when performing orderOfOperations
- Added statusCode tests for variations based on the openApiResponse property

## v1.0.1 - (2021-06-18)

### Overwrites

- extend overwrites to allow injection of objects and not just primitive values

## v1.0.0 - (2021-06-18)

## First Release

- Major overhaul from base release
- All feayures listed below
- All features listed below

Added:

Expand Down Expand Up @@ -75,7 +92,7 @@ Added:

### CLI options

- Resolve issue with overriding paths to defauls when not provided
- Resolve issue with overriding paths to defaults when not provided
- Extended hardcoded list of params to disable until they are passed in as config

## v0.0.5 - (2021-05-25)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ The "assignVariables" allows you to set Postman collection variables for easier
- **responseHeaderProp (String)** : The property for which the value will be taken from the response header and set the value as the pm.collectionVariables value.
- **requestBodyProp (String)** : The property for which the value will be taken from the request body and set the value as the pm.collectionVariables value.
- **value (String)** : The defined value that will be set as the pm.collectionVariables value.
- **name (string OPTIONAL | Default: openApiOperationId.responseProp** : The name that will be used to overwrite the default generated variable name
- **name (string OPTIONAL | Default: openApiOperationId.responseProp)** : The name that will be used to overwrite the default generated variable name

For more details, review the [assign-variables example](https://github.com/apideck-libraries/portman/tree/main/examples/testsuite-assign-variables).

Expand Down Expand Up @@ -482,7 +482,7 @@ Credits for this package for the hard work of [Nick Lloyd](https://github.com/ni

# Future ideas

- [ ] add task to initalize config files
- [ ] add task to initialize config files
- [ ] add interactive cli prompts
- [ ] render better error on Postman upload fail
- [ ] cache the Postman collection lookup during Postman upload
210 changes: 210 additions & 0 deletions __tests__/fixtures/portman-variations.crm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
{
"version": 1.0,
"tests": {
"contractTests": [
{
"openApiOperation": "*::/crm/*",
"excludeForOperations": [
"GET::/crm/companies"
],
"statusSuccess": {
"enabled": true
}
},
{
"openApiOperation": "*::/crm/*",
"responseTime": {
"enabled": true,
"maxMs": 300
}
},
{
"openApiOperation": "*::/crm/*",
"contentType": {
"enabled": true
}
},
{
"openApiOperation": "*::/crm/*",
"jsonBody": {
"enabled": true
}
},
{
"openApiOperation": "*::/crm/*",
"schemaValidation": {
"enabled": true
}
},
{
"openApiOperation": "*::/crm/*",
"headersPresent": {
"enabled": true
}
}
],
"contentTests": [
{
"openApiOperationId": "companiesAll",
"responseBodyTests": [
{
"key": "data[0].company_name",
"value": "Spacex"
}
]
}
],
"extendTests": [
{
"openApiOperationId": "companiesAll",
"tests": [
"pm.test('[GET] /crm/companies - Unify pagination limit', function(){pm.expect(pm.response.json().data.length).to.eql(3);});"
]
}
],
"variationTests": [
{
"openApiOperationId": "leadsAdd",
"variations": [
{
"name": "missingParams",
"openApiResponse": "402",
"overwrites": [
{
"overwriteRequestBody": [
{
"key": "name",
"value": "",
"overwrite": true
}
]
}
],
"tests": {
"contractTests": [
{
"statusCode": {
"enabled": true,
"code": 400
}
},
{
"jsonBody": {
"enabled": true
}
},
{
"schemaValidation": {
"enabled": true
}
}
],
"contentTests": [
{
"responseBodyTests": [
{
"key": "resource",
"value": "leads"
}
]
}
],
"extendTests": [
{
"tests": [
"\npm.test('say hello Portman', function(){ \n console.log('Hello Portman')\n});"
]
}
]
},
"assignVariables": [
{
"collectionVariables": [
{
"responseBodyProp": "data[0].id"
}
]
}
]
},
{
"name": "400",
"openApiResponse": "400",
"tests": {
"contractTests": [
{
"statusCode": {
"enabled": true,
"code": 333
}
},
{
"jsonBody": {
"enabled": true
}
},
{
"schemaValidation": {
"enabled": true
}
}
]
}
}
]
}
]
},
"assignVariables": [
{
"openApiOperationId": "companiesAll",
"collectionVariables": [
{
"responseBodyProp": "data[0].id"
}
]
}
],
"overwrites": [
{
"openApiOperationId": "companiesAdd",
"overwriteRequestBody": [
{
"key": "name",
"value": "Foo Inc. --{{$randomInt}}",
"overwrite": true
}
]
},
{
"openApiOperationId": "companiesAll",
"overwriteRequestQueryParams": [
{
"key": "limit",
"value": "4",
"overwrite": true
}
]
},
{
"openApiOperationId": "companiesUpdate",
"overwriteRequestHeaders": [
{
"key": "x-apideck-consumer-id",
"value": "portman-id-{{$randomInt}}",
"overwrite": true
}
]
},
{
"openApiOperationId": "companiesUpdate",
"overwriteRequestPathVariables": [
{
"key": "id",
"value": "123456789",
"overwrite": true
}
]
}
]
}
10 changes: 6 additions & 4 deletions examples/testsuite-assign-variables/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ These target options are both supported for defining a target. In case both are

### collectionVariables options:

- **collectionVariables (Array)** :
- **collectionVariables (Array)** :

Array of key/value pairs to set the Postman collection variables.

- **responseBodyProp (String)** : The property for which the value will be taken in the response body and set the value as the pm.collectionVariables value.
- **responseHeaderProp (String)** : The property for which the value will be taken in the response header and set the value as the pm.collectionVariables value.
- **requestBodyProp (String)** : The property for which the value will be taken in the request body and set the value as the pm.collectionVariables value.
Expand Down Expand Up @@ -398,7 +398,9 @@ if (typeof jsonData.data.company_name !== 'undefined') {
pm.test(
"[GET] /crm/leads/{id} - Content check if value for 'data.company_name' matches '{{leadsAdd.company_name}}'",
function () {
pm.expect(jsonData.data.company_name).to.eql(pm.environment.get('leadsAdd.company_name'))
pm.expect(jsonData.data.company_name).to.eql(
pm.collectionVariables.get('leadsAdd.company_name')
)
}
)
}
Expand Down
Loading

0 comments on commit d56a793

Please sign in to comment.