Skip to content

Commit 536cf9b

Browse files
committed
test: make test errors for proxyRoute easier to interpret
1 parent 9562b69 commit 536cf9b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

test/testProxyRoute.test.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,12 @@ describe('proxy express application', async () => {
389389
it('should be restarted by the api and proxy requests for a new host (e.g. gitlab.com) when a project at that host is ADDED via the API', async function () {
390390
// Tests that the proxy restarts properly after a project with a URL at a new host is added
391391

392-
// check that we do not have the Gitlab test repo set up yet
393-
let repo = await db.getRepoByUrl(TEST_GITLAB_REPO.url);
394-
expect(repo).to.be.null;
392+
// check that we don't have *any* repos at gitlab.com setup
393+
const numExistingGitlabRepos = (await db.getRepos({ url: /https:\/\/gitlab\.com/ })).length;
394+
expect(
395+
numExistingGitlabRepos,
396+
'There is a GitLab that exists in the database already, which is NOT expected when running this test',
397+
).to.be.equal(0);
395398

396399
// create the repo through the API, which should force the proxy to restart to handle the new domain
397400
const res = await chai
@@ -401,11 +404,15 @@ describe('proxy express application', async () => {
401404
.send(TEST_GITLAB_REPO);
402405
res.should.have.status(200);
403406

404-
// confirm that the repo was created in teh DB
405-
repo = await db.getRepoByUrl(TEST_GITLAB_REPO.url);
407+
// confirm that the repo was created in the DB
408+
const repo = await db.getRepoByUrl(TEST_GITLAB_REPO.url);
406409
expect(repo).to.not.be.null;
407410

408-
// proxy a fetch request to the new repo
411+
// and that our initial query for repos would have picked it up
412+
const numCurrentGitlabRepos = (await db.getRepos({ url: /https:\/\/gitlab\.com/ })).length;
413+
expect(numCurrentGitlabRepos).to.be.equal(1);
414+
415+
// proxy a request to the new repo
409416
const res2 = await chai
410417
.request(proxy.getExpressApp())
411418
.get(`/${TEST_GITLAB_REPO.proxyUrlPrefix}/info/refs?service=git-upload-pack`)
@@ -435,7 +442,10 @@ describe('proxy express application', async () => {
435442
res.should.have.status(200);
436443

437444
// confirm that its gone from the DB
438-
repo = await db.getRepoByUrl(TEST_GITLAB_REPO.url);
445+
repo = await db.getRepoByUrl(
446+
TEST_GITLAB_REPO.url,
447+
'The GitLab repo still existed in the database after it should have been deleted...',
448+
);
439449
expect(repo).to.be.null;
440450

441451
// give the proxy half a second to restart

0 commit comments

Comments
 (0)