fix: proxy preparations mismatch bug#1284
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1284 +/- ##
=======================================
Coverage 83.35% 83.35%
=======================================
Files 70 70
Lines 3004 3004
Branches 499 499
=======================================
Hits 2504 2504
Misses 397 397
Partials 103 103 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kriswest
left a comment
There was a problem hiding this comment.
Looks good to me but could include a test... The tests in testProxyRoute are closest to this...
E.g. the before at
git-proxy/test/testProxyRoute.test.js
Lines 408 to 439 in 85e418f
|
@kriswest Rather than modifying the it('should create the default repo if it does not exist', async function () {
// Remove the default repo from the db and check it no longer exists
await cleanupRepo(TEST_DEFAULT_REPO.url);
const repo = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
expect(repo).to.be.null;
// Restart the proxy
await proxy.stop();
await proxy.start();
// Check that the default repo was created in the db
const repo2 = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
expect(repo2).to.not.be.null;
// Check that the default repo isn't duplicated on subsequent restarts
await proxy.stop();
await proxy.start();
const repo3 = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
expect(repo3).to.not.be.null;
expect(repo3._id).to.equal(repo2._id);
});Does this look correct? 🤔 |
|
@jescalada I think that approach to a test is valid, however this bit at the end may not be right: const repo3 = await db.getRepoByUrl(TEST_DEFAULT_REPO.url);
expect(repo3).to.not.be.null;
expect(repo3._id).to.equal(repo2._id);Who's to say that it doesn't return the first one that was created, meaning it will always pass even if a duplicate was created? Use |
c94acb0 to
3afa917
Compare
|
@kriswest Updated the test as follows: const allRepos = await db.getRepos();
const matchingRepos = allRepos.filter((r) => r.url === TEST_DEFAULT_REPO.url);
expect(matchingRepos).to.have.length(1);Will be merging this to convert the test to Vitest and speed up the merge process on that PR 😃 |
Fixes #1282
Fixes #1278