From 3aa6c7e98266d06d37e657d2351ad3b4466a099d Mon Sep 17 00:00:00 2001 From: confused_techie Date: Wed, 26 Jun 2024 08:25:34 -0700 Subject: [PATCH] Add safety to avoid featureDetection failure --- src/vcs_providers/github.js | 14 ++++++++++++-- tests/full/publish-version.test.js | 4 +--- tests/full/publish.test.js | 2 -- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/vcs_providers/github.js b/src/vcs_providers/github.js index ae68ed48..3a083b46 100644 --- a/src/vcs_providers/github.js +++ b/src/vcs_providers/github.js @@ -538,8 +538,18 @@ class GitHub extends Git { // Now with our utility functions here defined, lets call them and build // our featureObject let tags = await this.tags(userObj, ownerRepo); - console.log("tags value"); - console.log(tags); + + if (!tags.ok) { + // We failed to get the tags data for featureDetection. + // This would be rather difficult to occur in real life, but this safety check + // becomes necessary in testing, as the mocked endpoints won't stay alive + // after the HTTP request returns. + return { + ok: false, + content: tags + }; + } + // Sort the tags into descending order tags.content.sort((a, b) => { return semver.rcompare(a.name, b.name)} ); diff --git a/tests/full/publish-version.test.js b/tests/full/publish-version.test.js index 1fc6fb6a..dd1428e6 100644 --- a/tests/full/publish-version.test.js +++ b/tests/full/publish-version.test.js @@ -102,9 +102,7 @@ describe("publish package versions", () => { }); - afterAll(async () => { - await new Promise(process.nextTick); - + afterAll(async () => { // Lets delete our test package versions await database.removePackageByName("d-pulsar-package", true); diff --git a/tests/full/publish.test.js b/tests/full/publish.test.js index 8309a34c..134e7c32 100644 --- a/tests/full/publish.test.js +++ b/tests/full/publish.test.js @@ -28,8 +28,6 @@ describe("publish packages", () => { }); afterAll(() => { - await new Promise(process.nextTick); - nock.cleanAll(); nock.enableNetConnect(); });