Skip to content

Commit

Permalink
updated readme and tests for local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-sharma-08 committed Sep 4, 2024
1 parent 6e3d9ac commit 1f3e01f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ runner.run(collection, {
// Globals (a "VariableScope" from the SDK)
globals: new sdk.VariableScope(),

// Locals (a "variableScope" from the SDK) local variables will be initialised by this.
locals: new sdk.VariableScope(),

// Execute a folder/request using id/name or path
entrypoint: {
// execute a folder/request using id or name
Expand Down
20 changes: 17 additions & 3 deletions test/integration/inherited-entities/pm-variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ var _ = require('lodash'),
describe('pm.variables', function () {
var testRun,
runOptions = {
locals: {
values: [
{ key: 'key-1', value: 'local-value-1', name: 'key-1', enabled: true },
{ key: 'key-7', value: 'local-value-7', name: 'key-7', enabled: true }
]
},
data: [{
'key-4': 'data-value-4'
}],
Expand Down Expand Up @@ -95,10 +101,11 @@ describe('pm.variables', function () {

consoleLogs.forEach(function (consoleLog) {
expect(consoleLog).to.eql({
'key-1': 'global-value-1',
'key-1': 'local-value-1',
'key-2': 'coll-value-2',
'key-3': 'env-value-3',
'key-4': 'data-value-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
});
Expand All @@ -107,14 +114,14 @@ describe('pm.variables', function () {

it('should be honoured in request URL', function () {
var url = testRun.request.getCall(0).args[3].url.toString(),
expectedParam = 'global-value-1:coll-value-2:env-value-3:data-value-4:global-value-5';
expectedParam = 'local-value-1:coll-value-2:env-value-3:data-value-4:global-value-5';

expect(url).to.equal('https://postman-echo.com/get?param=' + expectedParam);
});

it('should be honoured in auth', function () {
var response = testRun.response.getCall(0).args[2],
expectedToken = 'global-value-1:coll-value-2:env-value-3:data-value-4:global-value-5';
expectedToken = 'local-value-1:coll-value-2:env-value-3:data-value-4:global-value-5';

expect(response.json()).to.deep.nested.include({
'headers.authorization': 'Bearer ' + expectedToken
Expand Down Expand Up @@ -234,6 +241,7 @@ describe('pm.variables', function () {
'key-2': 'modified-1',
'key-3': 'env-value-3',
'key-4': 'data-value-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand All @@ -246,6 +254,7 @@ describe('pm.variables', function () {
'key-2': 'modified-2',
'key-3': 'modified-2',
'key-4': 'data-value-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand All @@ -258,6 +267,7 @@ describe('pm.variables', function () {
'key-2': 'modified-2',
'key-3': 'modified-3',
'key-4': 'modified-3',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand All @@ -270,6 +280,7 @@ describe('pm.variables', function () {
'key-2': 'modified-2',
'key-3': 'modified-3',
'key-4': 'modified-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand All @@ -282,6 +293,7 @@ describe('pm.variables', function () {
'key-2': 'modified-1',
'key-3': 'modified-3',
'key-4': 'modified-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand All @@ -294,6 +306,7 @@ describe('pm.variables', function () {
'key-2': 'modified-1',
'key-3': 'modified-3',
'key-4': 'modified-3',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand Down Expand Up @@ -361,6 +374,7 @@ describe('pm.variables', function () {
'key-2': 'coll-value-2',
'key-3': 'env-value-3',
'key-4': 'data-value-4',
'key-7': 'local-value-7',
'vault:key5': 'global-value-5',
'vault:key6': 'vault-value-6'
}
Expand Down

0 comments on commit 1f3e01f

Please sign in to comment.