Skip to content

Commit

Permalink
✅ Fix create resubmit test
Browse files Browse the repository at this point in the history
One of our tests currently checks resubmitting a create op after
reconnecting during submission.

However, since reconnection happens so quickly, this test case can cause
two commit attempts in parallel.

We currently only wait for the first request to resolve, which means
that the second request can continue into the next test, causing
unexpected test failures.

This change waits for both acks to be sent before finishing the test.
  • Loading branch information
alecgibson committed May 29, 2024
1 parent 7abe650 commit 75b2a14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/client/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,15 @@ module.exports = function() {
next();
});

var doc = connection.get('dogs', 'fido');
doc.create({age: 3}, function(error) {
expect(doc.version).to.equal(1);
done(error);
var count = 0;
backend.use('reply', function(message, next) {
next();
if (message.reply.a === 'op') count++;
if (count === 2) done();
});

var doc = connection.get('dogs', 'fido');
doc.create({age: 10}, errorHandler(done));
});

it('does not fail when resubmitting a create op on a doc that was deleted', function(done) {
Expand Down

0 comments on commit 75b2a14

Please sign in to comment.