Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

When iterating a data file, loop back to the beginning... #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ThePieBandit wants to merge 1 commit into postmanlabs:develop
base: develop
Choose a base branch
Loading
from ThePieBandit:develop

Conversation

Copy link

@ThePieBandit ThePieBandit commented Jun 24, 2022

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:

  1. When uploading the data file, it sets the iteration count to the length of the data array, in this case, 2.
  2. If the collection is run like that, it will run once with foo and once with bar.
  3. 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.

image

Copy link
Author

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' });
 });
 });
 });
 });
});

Copy link

codecov bot commented Jun 29, 2022
edited
Loading

Codecov Report

Merging #1218 (f420be6) into develop (946ee96) will decrease coverage by 0.01%.
The diff coverage is 100.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%) ⬇️
legacy 48.48% <100.00%> (-0.04%) ⬇️
unit 43.26% <0.00%> (+0.02%) ⬆️

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%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /