Core development
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
This commit is contained in:
parent
ae4f0f141b
commit
c29e128814
3 changed files with 15 additions and 29 deletions
|
@ -289,15 +289,13 @@ export default class Application extends EventEmitter {
|
||||||
if (version !== 'static') {
|
if (version !== 'static') {
|
||||||
let indexPath = this.ctx.util.getPathFromRoot(`./${this.name}/${version}/index.mjs`)
|
let indexPath = this.ctx.util.getPathFromRoot(`./${this.name}/${version}/index.mjs`)
|
||||||
await this.fs.stat(indexPath).catch((err) => {
|
await this.fs.stat(indexPath).catch((err) => {
|
||||||
return Promise.reject(new Error(`Application ${this.name} version ${version} was missing index.mjs: ${err.message}`))
|
return Promise.reject(new Error(`Version was missing index.mjs: ${err.message}`))
|
||||||
})
|
|
||||||
let module = await import(this.ctx.util.getUrlFromRoot(`./${this.name}/${version}/index.mjs`)).catch((err) => {
|
|
||||||
return Promise.reject(new Error(`Application ${this.name} version ${version} failed to load index.mjs: ${err.message}`))
|
|
||||||
})
|
})
|
||||||
|
let module = await import(this.ctx.util.getUrlFromRoot(`./${this.name}/${version}/index.mjs`))
|
||||||
this.registerModule(module, version)
|
this.registerModule(module, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
let errTimeout = new Error(`Application ${this.name} version ${version} timed out (took over ${this.config.startWaitUntilFail}ms) while running start()`)
|
let errTimeout = new Error(`Version timed out (took over ${this.config.startWaitUntilFail}ms) while running start()`)
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
await new Promise((res, rej) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -312,7 +310,7 @@ export default class Application extends EventEmitter {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!this.http.active) {
|
if (!this.http.active) {
|
||||||
return Promise.reject(new Error(`Application ${this.name} version ${version} did not call http.createServer()`))
|
return Promise.reject(new Error(`Version did not call http.createServer()`))
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastErr = null
|
let lastErr = null
|
||||||
|
@ -326,7 +324,7 @@ export default class Application extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(new Error(`Application ${this.name} version ${version} failed to start properly: ${lastErr.message}`))
|
return Promise.reject(new Error(`Version failed to start properly: ${lastErr.message}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
closeServer() {
|
closeServer() {
|
||||||
|
|
|
@ -60,8 +60,6 @@ t.describe('#runVersion("static")', function() {
|
||||||
|
|
||||||
assert.match(err.message, /http/i)
|
assert.match(err.message, /http/i)
|
||||||
assert.match(err.message, /createServer/i)
|
assert.match(err.message, /createServer/i)
|
||||||
assert.match(err.message, /static/)
|
|
||||||
assert.match(err.message, new RegExp(app.name))
|
|
||||||
assert.match(err.message, /call/i)
|
assert.match(err.message, /call/i)
|
||||||
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
||||||
})
|
})
|
||||||
|
@ -74,9 +72,7 @@ t.describe('#runVersion("static")', function() {
|
||||||
|
|
||||||
assert.match(err.message, /time/i)
|
assert.match(err.message, /time/i)
|
||||||
assert.match(err.message, /out/i)
|
assert.match(err.message, /out/i)
|
||||||
assert.match(err.message, /static/)
|
|
||||||
assert.match(err.message, /50ms/)
|
assert.match(err.message, /50ms/)
|
||||||
assert.match(err.message, new RegExp(app.name))
|
|
||||||
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -107,10 +103,7 @@ t.describe('#runVersion("static")', function() {
|
||||||
app.registerModule(defaultHandler(handler))
|
app.registerModule(defaultHandler(handler))
|
||||||
|
|
||||||
let err = await assert.isRejected(app.runVersion('static'))
|
let err = await assert.isRejected(app.runVersion('static'))
|
||||||
assert.match(err.message, /app/i)
|
|
||||||
assert.match(err.message, /failed/i)
|
assert.match(err.message, /failed/i)
|
||||||
assert.match(err.message, /static/i)
|
|
||||||
assert.match(err.message, /testapp/i)
|
|
||||||
assert.match(err.message, /400/i)
|
assert.match(err.message, /400/i)
|
||||||
assert.strictEqual(called, 3)
|
assert.strictEqual(called, 3)
|
||||||
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
assert.strictEqual(ctx.db.data.core.testapp.active, 'static')
|
||||||
|
@ -128,10 +121,7 @@ t.describe('#runVersion("static")', function() {
|
||||||
let start = performance.now()
|
let start = performance.now()
|
||||||
let err = await assert.isRejected(app.runVersion('static'))
|
let err = await assert.isRejected(app.runVersion('static'))
|
||||||
let end = performance.now()
|
let end = performance.now()
|
||||||
assert.match(err.message, /app/i)
|
|
||||||
assert.match(err.message, /failed/i)
|
assert.match(err.message, /failed/i)
|
||||||
assert.match(err.message, /static/i)
|
|
||||||
assert.match(err.message, /testapp/i)
|
|
||||||
assert.match(err.message, /time/i)
|
assert.match(err.message, /time/i)
|
||||||
assert.match(err.message, /out/i)
|
assert.match(err.message, /out/i)
|
||||||
assert.match(err.message, /30ms/i)
|
assert.match(err.message, /30ms/i)
|
||||||
|
@ -154,10 +144,7 @@ t.describe('#runVersion("static")', function() {
|
||||||
app.registerModule(defaultHandler(handler))
|
app.registerModule(defaultHandler(handler))
|
||||||
|
|
||||||
let err = await assert.isRejected(app.runVersion('static'))
|
let err = await assert.isRejected(app.runVersion('static'))
|
||||||
assert.match(err.message, /app/i)
|
|
||||||
assert.match(err.message, /failed/i)
|
assert.match(err.message, /failed/i)
|
||||||
assert.match(err.message, /static/i)
|
|
||||||
assert.match(err.message, /testapp/i)
|
|
||||||
assert.match(err.message, /400/i)
|
assert.match(err.message, /400/i)
|
||||||
|
|
||||||
await app.http.closeServer()
|
await app.http.closeServer()
|
||||||
|
@ -170,7 +157,7 @@ t.describe('#runVersion("static")', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
t.skip().describe('#runVersion("version")', function() {
|
t.describe('#runVersion("version")', function() {
|
||||||
const assertConfig = util.getPathFromRoot('./db_test_applicationrun.json')
|
const assertConfig = util.getPathFromRoot('./db_test_applicationrun.json')
|
||||||
const assertPort = 22345
|
const assertPort = 22345
|
||||||
let ctx
|
let ctx
|
||||||
|
@ -220,8 +207,6 @@ t.skip().describe('#runVersion("version")', function() {
|
||||||
assert.notStrictEqual(err, assertNotError)
|
assert.notStrictEqual(err, assertNotError)
|
||||||
assert.match(err.message, new RegExp(assertNotError.message))
|
assert.match(err.message, new RegExp(assertNotError.message))
|
||||||
assert.match(err.message, /index\.mjs/i)
|
assert.match(err.message, /index\.mjs/i)
|
||||||
assert.match(err.message, /testnoexisting/i)
|
|
||||||
assert.match(err.message, /v100/i)
|
|
||||||
assert.match(err.message, /missing/i)
|
assert.match(err.message, /missing/i)
|
||||||
assert.strictEqual(stubFsStat.firstCall[0], assertTarget)
|
assert.strictEqual(stubFsStat.firstCall[0], assertTarget)
|
||||||
|
|
||||||
|
@ -237,10 +222,7 @@ t.skip().describe('#runVersion("version")', function() {
|
||||||
|
|
||||||
let err = await assert.isRejected(app.runVersion('v99'))
|
let err = await assert.isRejected(app.runVersion('v99'))
|
||||||
assert.notStrictEqual(err, assertError)
|
assert.notStrictEqual(err, assertError)
|
||||||
assert.match(err.message, new RegExp(assertError.message))
|
assert.strictEqual(err.message, assertError.message)
|
||||||
assert.match(err.message, /testnoexisting/i)
|
|
||||||
assert.match(err.message, /v99/i)
|
|
||||||
assert.match(err.message, /index\.mjs/i)
|
|
||||||
|
|
||||||
assert.strictEqual(app.ctx.db.data.core.testnoexisting.active, 'v99')
|
assert.strictEqual(app.ctx.db.data.core.testnoexisting.active, 'v99')
|
||||||
let checkDb = await lowdb({}, ctx.log, assertConfig)
|
let checkDb = await lowdb({}, ctx.log, assertConfig)
|
||||||
|
@ -252,8 +234,6 @@ t.skip().describe('#runVersion("version")', function() {
|
||||||
await fs.writeFile(util.getPathFromRoot('./testnoexisting/v98/index.mjs'), ``)
|
await fs.writeFile(util.getPathFromRoot('./testnoexisting/v98/index.mjs'), ``)
|
||||||
|
|
||||||
let err = await assert.isRejected(app.runVersion('v98'))
|
let err = await assert.isRejected(app.runVersion('v98'))
|
||||||
assert.match(err.message, /testnoexisting/i)
|
|
||||||
assert.match(err.message, /v98/i)
|
|
||||||
assert.match(err.message, /start/i)
|
assert.match(err.message, /start/i)
|
||||||
|
|
||||||
assert.strictEqual(app.ctx.db.data.core.testnoexisting.active, 'v98')
|
assert.strictEqual(app.ctx.db.data.core.testnoexisting.active, 'v98')
|
||||||
|
|
|
@ -363,3 +363,11 @@ t.describe('#init()', function() {
|
||||||
assert.ok(application.provider instanceof FakeProvider)
|
assert.ok(application.provider instanceof FakeProvider)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.describe('#runApplication()', function() {
|
||||||
|
let core
|
||||||
|
|
||||||
|
t.beforeEach(function() {
|
||||||
|
core = new Core(db, util, createFakeLog(), function() {})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue