postman-runtime
postman-runtime copied to clipboard
When iterating a data file, loop back to the beginning...
rather than repeat the last element. For example, take the following data file:
[
{"inputData":"foo"},
{"inputData":"bar"}
]
If I were to run a collection with the following GET API: https://postman-echo.com/get?foo1={{inputData}} using the runner, several things happen:
- When uploading the data file, it sets the iteration count to the length of the data array, in this case, 2.
- If the collection is run like that, it will run once with foo and once with bar.
- After setting the data file, the iteration count can be changed. This can be useful for data seeding into an environment. For example, it can be set to 5.
the current behavior is to run once with foo and 4 times with bar. For data seeding, this is not ideal. this enhancement causes the iteration count, if greater than the number of rows in the data, to return to the first index of the data file and continue to invoke the APIs in the collection.
Note: I tried to write a test, but was unsuccessful. I wasn't sure how I could just unit test the getIterationData method without exposing it. I tried
var expect = require('chai').expect,
Waterfall = require('../../lib/runner/extensions/waterfall.command.js');
describe('runner extensions', function () {
describe('Waterfall', function () {
describe('getIterationData', function () {
describe('when iteration count is less than the size of the data', function () {
it('should return the index of the data', function () {
var data = [
{ a: 'b' },
{ c: 'd' },
{ e: 'f' }
];
expect(Waterfall.getIterationData(data, 1)).to.eql({ c: 'd' });
});
});
describe('when iteration count is more than the size of the data', function () {
it('should loop back around to the beginning of the data', function () {
var data = [
{ a: 'b' },
{ c: 'd' },
{ e: 'f' }
];
expect(Waterfall.getIterationData(data, 2)).to.eql({ e: 'f' });
expect(Waterfall.getIterationData(data, 3)).to.eql({ a: 'b' });
expect(Waterfall.getIterationData(data, 5)).to.eql({ e: 'f' });
expect(Waterfall.getIterationData(data, 7)).to.eql({ c: 'd' });
});
});
});
});
});
Codecov Report
Merging #1218 (f420be6) into develop (946ee96) will decrease coverage by
0.01%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## develop #1218 +/- ##
===========================================
- Coverage 79.57% 79.56% -0.02%
===========================================
Files 42 42
Lines 2972 2970 -2
Branches 856 855 -1
===========================================
- Hits 2365 2363 -2
Misses 607 607
Flag | Coverage Δ | |
---|---|---|
integration | 69.46% <100.00%> (-0.03%) |
:arrow_down: |
legacy | 48.48% <100.00%> (-0.04%) |
:arrow_down: |
unit | 43.26% <0.00%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
lib/runner/extensions/waterfall.command.js | 93.67% <100.00%> (-0.16%) |
:arrow_down: |
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more