diff --git a/core/core.mjs b/core/core.mjs index 27e190c..36293ba 100644 --- a/core/core.mjs +++ b/core/core.mjs @@ -94,7 +94,7 @@ export default class Core { hasCluster = true } } catch (err) { - this.log.error(err, `Error creating application ${name} with provider ${this.db.config[name].provider}: ${err.message}`) + this.log.error(err, `Error creating application ${name} with provider ${this.db.config[name].provider} with config ${JSON.stringify(this.db.config[name])}: ${err.message}`) } } @@ -128,6 +128,7 @@ export default class Core { } if (names.length && !this.applications.length) { + this.log.error('None of the application were successful in running') return Promise.reject(new Error('None of the application were successful in running')) } } diff --git a/core/providers/git.mjs b/core/providers/git.mjs index fa93ed4..d758479 100644 --- a/core/providers/git.mjs +++ b/core/providers/git.mjs @@ -55,10 +55,5 @@ export default class GitProvider { if (typeof(this.config.url) !== 'string') return Promise.reject(new Error('url was not a valid url')) try { new URL(this.config.url) } catch (err) { return Promise.reject(new Error('url was not a valid url: ' + err.message)) } - - return this.getLatestVersion() - .catch(function(err) { - return Promise.reject(new Error(`Error fetching latest release: ${err.message}`)) - }) } } diff --git a/package.json b/package.json index 20db506..97ad4a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-core", - "version": "3.0.0-beta.16", + "version": "3.0.0", "description": "Core boiler plate code to install node server as windows service", "main": "index.mjs", "scripts": { diff --git a/test/providers/git.test.integration.mjs b/test/providers/git.test.integration.mjs index 2f965f5..f13cc36 100644 --- a/test/providers/git.test.integration.mjs +++ b/test/providers/git.test.integration.mjs @@ -18,26 +18,24 @@ t.timeout(5000).describe('#getLatestVersion()', function() { assert.ok(version.link) assert.match(version.link, /\/attachments\//) }) -}) -t.timeout(5000).describe('#checkConfig()', function() { t.test('should fail if link does not return json repository object', async function() { - let err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/repos/thething/ProgramQueuer' }).checkConfig()) + let err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/repos/thething/ProgramQueuer' }).getLatestVersion()) assert.match(err.message, /valid/i) assert.match(err.message, /repository/i) - err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/orgs/nfp/repos' }).checkConfig()) + err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/orgs/nfp/repos' }).getLatestVersion()) assert.match(err.message, /service-core/i) assert.match(err.message, /release/i) }) t.test('should fail if no active release repository with assets', async function() { - let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/eltro/releases' }).checkConfig()) + let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/eltro/releases' }).getLatestVersion()) assert.match(err.message, /service-core/i) assert.match(err.message, /release/i) }) t.test('should fail on private repositories', async function() { - let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases' }).checkConfig()) + let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases' }).getLatestVersion()) assert.match(err.message, /fail/i) assert.match(err.message, /404/i) assert.match(err.message, /release/i) @@ -45,19 +43,19 @@ t.timeout(5000).describe('#checkConfig()', function() { t.test('should otherwise succeed', function() { return new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/sc-helloworld/releases' }) - .checkConfig() + .getLatestVersion() }) let test = t if (!process.env.gittesttoken) { - console.log('Skipping "git.test.integration: #checkConfig() should succeed on private repo with token"') + console.log('Skipping "git.test.integration: #getLatestVersion() should succeed on private repo with token"') test = test.skip() } test.test('should succeed on private repo with token', function() { return new GitProvider({ token: process.env.gittesttoken.trim(), url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases', - }).checkConfig() + }).getLatestVersion() }) }) diff --git a/test/providers/git.test.mjs b/test/providers/git.test.mjs index 2332477..07e2b72 100644 --- a/test/providers/git.test.mjs +++ b/test/providers/git.test.mjs @@ -190,19 +190,10 @@ t.describe('#checkConfig()', function() { } }) - t.test('should call requester with correct config and url', async function() { - const assertError = new Error('Toki wo Koeta Yoru') - const assertRequestConfig = { a: 1 } + t.test('should not call requester with correct config and url', async function() { const assertUrl = 'http://test' - let provider = new GitProvider({ url: assertUrl }, stub()) - provider.requestConfig = assertRequestConfig - provider.requester.rejects(assertError) - - let err = await assert.isRejected(provider.checkConfig()) - assert.notStrictEqual(err, assertError) - assert.match(err.message, new RegExp(assertError.message)) - assert.strict(provider.requester.firstCall[0], assertRequestConfig) - assert.strict(provider.requester.firstCall[1], assertUrl) + let err = await provider.checkConfig() + assert.notOk(provider.requester.called) }) })