Skip to content

Commit

Permalink
feat: do nothing on conflict for save pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Dec 23, 2024
1 parent 22a9f7c commit 4181b95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/repositories/pull-request-repository.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { knex } from '../../db/knex-database-connection.js';

async function save({ number, repositoryName }) {
return knex('pull_requests').insert({ number, repositoryName });
return knex('pull_requests').insert({ number, repositoryName }).onConflict().ignore();
}

async function isAtLeastOneMergeInProgress(repositoryName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ describe('PullRequestRepository', function () {
isMerging: false,
});
});

it('should ignore on conflict', async function () {
await pullRequestRepository.save({ number: 123, repositoryName: 'pix-sample-repo' });
await pullRequestRepository.save({ number: 123, repositoryName: 'pix-sample-repo' });

const result = await knex('pull_requests').select().where({ number: 123, repositoryName: 'pix-sample-repo' });
expect(result).to.be.lengthOf(1);
});
});

describe('#isAtLeastOneMergeInProgress', function () {
Expand Down

0 comments on commit 4181b95

Please sign in to comment.