Compare commits
No commits in common. "1995b38510654eae00bdc1fcc65d62135b9e0388" and "cb5de72e13fc4fd91b0c420a8f2f6d409b53fce8" have entirely different histories.
1995b38510
...
cb5de72e13
5 changed files with 28 additions and 13 deletions
|
@ -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} with config ${JSON.stringify(this.db.config[name])}: ${err.message}`)
|
||||
this.log.error(err, `Error creating application ${name} with provider ${this.db.config[name].provider}: ${err.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,6 @@ 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'))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,5 +55,10 @@ 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}`))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "service-core",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.0-beta.17",
|
||||
"description": "Core boiler plate code to install node server as windows service",
|
||||
"main": "index.mjs",
|
||||
"scripts": {
|
||||
|
|
|
@ -18,24 +18,26 @@ 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' }).getLatestVersion())
|
||||
let err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/repos/thething/ProgramQueuer' }).checkConfig())
|
||||
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' }).getLatestVersion())
|
||||
err = await assert.isRejected(new GitProvider({ url: 'http://git.nfp.is/api/v1/orgs/nfp/repos' }).checkConfig())
|
||||
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' }).getLatestVersion())
|
||||
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/thething/eltro/releases' }).checkConfig())
|
||||
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' }).getLatestVersion())
|
||||
let err = await assert.isRejected(new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/privateexample/releases' }).checkConfig())
|
||||
assert.match(err.message, /fail/i)
|
||||
assert.match(err.message, /404/i)
|
||||
assert.match(err.message, /release/i)
|
||||
|
@ -43,19 +45,19 @@ t.timeout(5000).describe('#getLatestVersion()', function() {
|
|||
|
||||
t.test('should otherwise succeed', function() {
|
||||
return new GitProvider({ url: 'https://git.nfp.is/api/v1/repos/TheThing/sc-helloworld/releases' })
|
||||
.getLatestVersion()
|
||||
.checkConfig()
|
||||
})
|
||||
|
||||
let test = t
|
||||
if (!process.env.gittesttoken) {
|
||||
console.log('Skipping "git.test.integration: #getLatestVersion() should succeed on private repo with token"')
|
||||
console.log('Skipping "git.test.integration: #checkConfig() 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',
|
||||
}).getLatestVersion()
|
||||
}).checkConfig()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -190,10 +190,19 @@ t.describe('#checkConfig()', function() {
|
|||
}
|
||||
})
|
||||
|
||||
t.test('should not call requester with correct config and url', async 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 }
|
||||
const assertUrl = 'http://test'
|
||||
|
||||
let provider = new GitProvider({ url: assertUrl }, stub())
|
||||
let err = await provider.checkConfig()
|
||||
assert.notOk(provider.requester.called)
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue