Skip to content

Commit

Permalink
Merge pull request #65 from mozilla-services/64-support-falsy-batch-l…
Browse files Browse the repository at this point in the history
…imit

Add safety check if batch limit setting is falsy (fixes #64)
  • Loading branch information
n1k0 committed Jul 15, 2015
2 parents 767ee54 + dc4e933 commit d1b8444
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default class Api {
return this.fetchServerSettings()
.then(serverSettings => {
const maxRequests = serverSettings["cliquet.batch_max_requests"];
if (records.length > maxRequests) {
if (maxRequests && records.length > maxRequests) {
return Promise.all(partition(records, maxRequests).map(chunk => {
return this.batch(bucketName, collName, chunk, options);
}))
Expand Down
11 changes: 11 additions & 0 deletions test/api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,17 @@ describe("Api", () => {
.should.become([1, 2, 3, 4]);
});

it("should not chunk batch requests if setting is falsy", () => {
api.fetchServerSettings.returns(Promise.resolve({
"cliquet.batch_max_requests": null
}));
sandbox.stub(root, "fetch").returns(fakeServerResponse(200, {
responses: []
}));
return api.batch("blog", "articles", moreOperations)
.then(_ => sinon.assert.calledOnce(fetch));
});

it("should map initial records to conflict objects", () => {
sandbox.stub(root, "fetch")
.onFirstCall().returns(fakeServerResponse(200, {
Expand Down
4 changes: 4 additions & 0 deletions test/scripts/setup-kinto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ git checkout $KINTO_RELEASE
cp $REPO_ROOT/test/scripts/kinto.ini $KINTO_ROOT/config/kinto.ini

make serve &

#Prevent race condition where integration tests start while server
# isn't running yet.
sleep 3

0 comments on commit d1b8444

Please sign in to comment.