From 14fead9c17c01037f87192faeaf86e3b04bdb120 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Fri, 16 Feb 2024 06:50:34 +0000 Subject: [PATCH] core: Update tests after moving version info --- package.json | 2 +- test/application.run.test.mjs | 44 +++++++++++++++++------------------ test/application.test.mjs | 6 ++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index e173e1e..62fb7bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "service-core", - "version": "3.0.1", + "version": "3.0.2", "description": "Core boiler plate code to install node server as windows service", "main": "index.mjs", "scripts": { diff --git a/test/application.run.test.mjs b/test/application.run.test.mjs index fbe0631..a803bb1 100644 --- a/test/application.run.test.mjs +++ b/test/application.run.test.mjs @@ -48,11 +48,11 @@ t.describe('#runVersion("static")', function() { assert.strictEqual(checkCtx.app, app) }) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('static')) assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.match(err.message, /http/i) assert.match(err.message, /createServer/i) @@ -64,11 +64,11 @@ t.describe('#runVersion("static")', function() { app.config.startWaitUntilFail = 50 app.registerModule(function() { return new Promise(function() {}) }) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('static')) assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.match(err.message, /time/i) assert.match(err.message, /out/i) @@ -87,11 +87,11 @@ t.describe('#runVersion("static")', function() { }) }) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) await app.runVersion('static') assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, 'static') + assert.strictEqual(app.ctx.version, 'static') assert.strictEqual(ctx.db.data.core.testapp.active, 'static') }) @@ -107,11 +107,11 @@ t.describe('#runVersion("static")', function() { app.config.heartbeatAttemptsWait = 5 app.registerModule(defaultHandler(handler)) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('static')) assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.match(err.message, /failed/i) assert.match(err.message, /400/i) @@ -129,13 +129,13 @@ t.describe('#runVersion("static")', function() { app.config.heartbeatAttemptsWait = 10 app.registerModule(defaultHandler(handler)) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let start = performance.now() let err = await assert.isRejected(app.runVersion('static')) let end = performance.now() assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.match(err.message, /failed/i) assert.match(err.message, /time/i) @@ -160,11 +160,11 @@ t.describe('#runVersion("static")', function() { app.config.heartbeatAttemptsWait = 5 app.registerModule(defaultHandler(handler)) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') let err = await assert.isRejected(app.runVersion('static')) assert.match(err.message, /failed/i) assert.match(err.message, /400/i) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') await app.closeServer() app.registerModule(defaultHandler(handler)) @@ -185,11 +185,11 @@ t.describe('#runVersion("static")', function() { app.registerModule(defaultHandler(handler)) app.isSlave = true - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) await app.runVersion('static') assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, 'static') + assert.strictEqual(app.ctx.version, 'static') assert.strictEqual(called, 0) assert.strictEqual(ctx.db.data.core.testapp.active, 'static') @@ -240,11 +240,11 @@ t.describe('#runVersion("version")', function() { app.config.port = assertPort stubFsStat.rejects(assertNotError) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('v100')) assert.strictEqual(app.fresh, true) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.notStrictEqual(err, assertNotError) assert.match(err.message, new RegExp(assertNotError.message)) @@ -262,11 +262,11 @@ t.describe('#runVersion("version")', function() { await fs.mkdir(util.getPathFromRoot('./testnoexisting/v99'), { recursive: true }) await fs.writeFile(util.getPathFromRoot('./testnoexisting/v99/index.mjs'), `throw new Error('${assertError.message}')`) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('v99')) assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.notStrictEqual(err, assertError) assert.strictEqual(err.message, assertError.message) @@ -280,12 +280,12 @@ t.describe('#runVersion("version")', function() { await fs.mkdir(util.getPathFromRoot('./testnoexisting/v98'), { recursive: true }) await fs.writeFile(util.getPathFromRoot('./testnoexisting/v98/index.mjs'), ``) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) let err = await assert.isRejected(app.runVersion('v98')) assert.strictEqual(app.fresh, false) assert.match(err.message, /start/i) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.ctx.db.data.core.testnoexisting.active, 'v98') let checkDb = await lowdb({}, ctx.log, assertConfig) @@ -302,11 +302,11 @@ t.describe('#runVersion("version")', function() { app.ctx.log.info.reset() app.ctx.log.event.info.reset() - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.fresh, true) await app.runVersion('v97') assert.strictEqual(app.fresh, false) - assert.strictEqual(app.running, 'v97') + assert.strictEqual(app.ctx.version, 'v97') assert.ok(app.ctx.log.info.called) assert.ok(app.ctx.log.event.info.called) diff --git a/test/application.test.mjs b/test/application.test.mjs index ee476cb..336dc9a 100644 --- a/test/application.test.mjs +++ b/test/application.test.mjs @@ -74,7 +74,7 @@ t.describe('constructor()', function() { assert.strictEqual(app.ctx.sc.getLog, getLog) assert.strictEqual(app.name, assertName) assert.strictEqual(app.fresh, true) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(app.monitoringCluster, false) assert.deepStrictEqual(app.workers, {}) assert.strictEqual(app.isSlave, false) @@ -333,9 +333,9 @@ t.describe('#closeServer()', function() { const assertError = new Error('Moonlight Fiesta') stubCloseServer.rejects(assertError) - app.running = assertNotVersion + app.ctx.version = assertNotVersion let err = await assert.isRejected(app.closeServer()) - assert.strictEqual(app.running, '') + assert.strictEqual(app.ctx.version, '') assert.strictEqual(err, assertError) })