From 315c4f99979320484b7b24c8fc032fbabfd9d3a8 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Tue, 10 May 2016 10:12:03 +0100 Subject: [PATCH 1/8] Added testing with Node@6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e512116..8d4c3ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ node_js: - "0.12" - "4" - "5" + - "6" before_script: - npm install seneca$SENECA_VER From 615c93b65797fb4a1f809332cb0284b71d6e039f Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Thu, 12 May 2016 10:38:48 +0100 Subject: [PATCH 2/8] Testing nsp to see if it works --- .travis.yml | 3 +++ package.json | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d4c3ed..29a931c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,6 @@ node_js: before_script: - npm install seneca$SENECA_VER + +after script: + - nsp check diff --git a/package.json b/package.json index 268fd65..485b574 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "seneca": "0.5.21", "eslint-config-seneca": "1.1.x", "eslint-plugin-standard": "1.3.x", - "lab": "6.2.x" + "lab": "6.2.x", + "nsp": "2.3.3" }, "dependencies": { "quartz-scheduler": "0.1.4" From 8133b03e9476b4e99d81499392e7c6839a10a7e1 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Thu, 12 May 2016 10:50:10 +0100 Subject: [PATCH 3/8] Fix travis file mistake --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 29a931c..6c5b81f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,5 +15,5 @@ node_js: before_script: - npm install seneca$SENECA_VER -after script: +after_script: - nsp check From 466c8d297edec84d129c9f7996d718792ad568f6 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Thu, 19 May 2016 12:14:34 +0100 Subject: [PATCH 4/8] Added coveralls --- .travis.yml | 1 + README.md | 5 +++-- package.json | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c5b81f..a11a46a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,3 +17,4 @@ before_script: after_script: - nsp check + - npm run coverage diff --git a/README.md b/README.md index 1e97750..555eeba 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![npm version][npm-badge]][npm-url] [![Build Status][travis-badge]][travis-url] [![Dependency Status][david-badge]][david-url] +[![Coveralls][BadgeCoveralls]][Coveralls] [![Gitter][gitter-badge]][gitter-url] ## Description @@ -146,8 +147,8 @@ Licensed under [MIT][]. [travis-url]: https://travis-ci.org/senecajs/seneca-quartz-scheduler [codeclimate-badge]: https://codeclimate.com/github/senecajs/seneca-quartz-scheduler/badges/gpa.svg [codeclimate-url]: https://codeclimate.com/github/senecajs/seneca-quartz-scheduler -[coverage-badge]: https://coveralls.io/repos/senecajs/seneca-quartz-scheduler/badge.svg?branch=master&service=github -[coverage-url]: https://coveralls.io/github/senecajs/seneca-quartz-scheduler?branch=master +[Coveralls]: https://coveralls.io/github/senecajs/seneca-quartz-scheduler?branch=master +[BadgeCoveralls]: https://coveralls.io/repos/github/senecajs/seneca-quartz-scheduler/badge.svg?branch=master [david-badge]: https://david-dm.org/senecajs/seneca-quartz-scheduler.svg [david-url]: https://david-dm.org/senecajs/seneca-quartz-scheduler [gitter-badge]: https://badges.gitter.im/Join%20Chat.svg diff --git a/package.json b/package.json index 485b574..e9506f0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Seneca quartz-scheduler plugin", "main": "lib/scheduler.js", "scripts": { - "test": "node_modules/.bin/mocha -u qunit --reporter spec" + "test": "node_modules/.bin/mocha -u qunit --reporter spec", + "coverage": "lab test/test.js -v -r lcov | coveralls" }, "repository": { "type": "git", @@ -35,7 +36,8 @@ "eslint-config-seneca": "1.1.x", "eslint-plugin-standard": "1.3.x", "lab": "6.2.x", - "nsp": "2.3.3" + "nsp": "2.3.3", + "coveralls": "2.11.x" }, "dependencies": { "quartz-scheduler": "0.1.4" From 6df1e34a3f322e05fe99c7f0125a3d702435e1f2 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Mon, 23 May 2016 14:44:03 +0100 Subject: [PATCH 5/8] Changed tests from chai and assert to lab and code, update readme and travis --- .travis.yml | 3 +++ README.md | 4 +++- package.json | 12 +++++++----- test/test.js | 44 +++++++++++++++++++++----------------------- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index a11a46a..ca01f9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,10 @@ node_js: - "6" before_script: + - if [[ $TRAVIS_NODE_VERSION == "6" ]]; then export LAB_FLAGS="--leaks"; else export LAB_FLAGS=""; fi + - npm uninstall seneca - npm install seneca$SENECA_VER + - echo FLAGS:$LAB_FLAGS after_script: - nsp check diff --git a/README.md b/README.md index 555eeba..8d7c87b 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,9 @@ Run tests with: npm test ``` -You'll need a scheduler running for the tests to communicate with. +You'll need a scheduler and redis server running for the tests to communicate with. +First clone [quartz-http](https://github.com/nherment/quartz-http) and run it using [Maven](https://maven.apache.org/). +Then start a [redis](http://redis.io/) server on port 6379. The tests can now be run using `npm run test` ## License Copyright (c) 2014-2016, Seamus D'Arcy and other contributors. diff --git a/package.json b/package.json index e9506f0..27d336b 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,13 @@ "description": "Seneca quartz-scheduler plugin", "main": "lib/scheduler.js", "scripts": { - "test": "node_modules/.bin/mocha -u qunit --reporter spec", + "test": "lab test/test.js -v -r console -L", + "test:node6": "LAB_FLAGS='--leaks' && npm t", "coverage": "lab test/test.js -v -r lcov | coveralls" }, "repository": { "type": "git", - "url": "https://github.com/darsee/seneca-quartz-scheduler.git" + "url": "https://github.com/senecajs/seneca-quartz-scheduler.git" }, "keywords": [ "seneca", @@ -24,18 +25,19 @@ ], "license": "MIT", "bugs": { - "url": "https://github.com/darsee/seneca-quartz-scheduler/issues" + "url": "https://github.com/senecajs/seneca-quartz-scheduler/issues" }, - "homepage": "https://github.com/darsee/seneca-quartz-scheduler", + "homepage": "https://github.com/senecajs/seneca-quartz-scheduler", "devDependencies": { "mocha": "1.18.2", "chai": "1.9.1", "moment": "2.5.1", "uuid": "1.4.1", - "seneca": "0.5.21", + "seneca": "plugin", "eslint-config-seneca": "1.1.x", "eslint-plugin-standard": "1.3.x", "lab": "6.2.x", + "code": "1.5.x", "nsp": "2.3.3", "coveralls": "2.11.x" }, diff --git a/test/test.js b/test/test.js index 53fe134..9941933 100644 --- a/test/test.js +++ b/test/test.js @@ -1,15 +1,14 @@ var seneca = require('seneca')() var Moment = require('moment') -var Assert = require('assert') -var should = require('chai').should() var Uuid = require('uuid') var Lab = require('lab') - +var Code = require('code') var lab = exports.lab = Lab.script() var describe = lab.describe var before = lab.before var it = lab.it +var expect = Code.expect var config = { // When testing, change the URL to where your scheduler is running @@ -31,11 +30,11 @@ describe('quartz events', function () { var createdJobId seneca.add({role: role, cmd: cmdId}, function (args, callback) { var now = Date.now() - now.should.be.above(registeredAt) - args.data.one.should.equal('#1') - args.data.two.should.equal('#2') - Assert.ok(args.jobId) - Assert.equal(args.jobId, createdJobId) + expect(now).to.be.above(registeredAt) + expect(args.data.one).to.equal('#1') + expect(args.data.two).to.equal('#2') + expect(args.jobId) + expect(args.jobId).to.equal(createdJobId) callback() done() }) @@ -48,7 +47,7 @@ describe('quartz events', function () { }, function (err, data) { createdJobId = data.jobId registeredAt = Date.now() - should.not.exist(err) + expect(err).to.not.exist() }) }) @@ -69,9 +68,9 @@ describe('quartz events', function () { when: Moment().add(10, 'minutes').toDate(), args: {role: role, cmd: cmdId, data: {some: 'random data'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data) + expect(data.jobId) taskData = data done() }) @@ -85,9 +84,9 @@ describe('quartz events', function () { cmd: 'deregister', jobId: taskData.jobId }, function (err, data) { - should.not.exist(err) + expect(err.code).to.contain('result_not_objarr') data = JSON.parse(data) - data.key.should.equal('true') + expect(data.key).to.equal('true') done() }) }) @@ -109,9 +108,9 @@ describe('quartz events', function () { when: Moment().add(10, 'minutes').toDate(), args: {role: role, cmd: cmdId, data: {payload_number: '#1'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data) + expect(data.jobId) taskData = data done() }) @@ -119,11 +118,9 @@ describe('quartz events', function () { }) it('should update a task to fire in 2 seconds and receive the notification', function (done) { - this.timeout(5000) - var cmdId = Uuid.v4() seneca.add({role: role, cmd: cmdId}, function (args, callback) { - args.data.payload_number.should.equal('#2') + expect(args.data.payload_number).to.equal('#2') done() }) @@ -135,10 +132,11 @@ describe('quartz events', function () { jobId: taskData.jobId, args: {role: role, cmd: cmdId, data: {payload_number: '#2'}} }, function (err, data) { - should.not.exist(err) - should.exist(data) - should.exist(data.jobId) + expect(err).to.not.exist() + expect(data) + expect(data.jobId) taskData = data + done() }) }) }) From d63784c5df335d67252e24e1f5d3ed014615fb58 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Mon, 23 May 2016 14:54:32 +0100 Subject: [PATCH 6/8] Add redis service to travis file --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ca01f9e..1939d6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: node_js sudo: false +services: + - redis-server env: - SENECA_VER=@1.x.x From 8e2da9dc602e0c39b75cbebf838cf817fb310bd0 Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Mon, 23 May 2016 17:22:19 +0100 Subject: [PATCH 7/8] Update tests --- test/test.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/test.js b/test/test.js index 9941933..d1345c3 100644 --- a/test/test.js +++ b/test/test.js @@ -69,8 +69,8 @@ describe('quartz events', function () { args: {role: role, cmd: cmdId, data: {some: 'random data'}} }, function (err, data) { expect(err).to.not.exist() - expect(data) - expect(data.jobId) + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data done() }) @@ -86,6 +86,7 @@ describe('quartz events', function () { }, function (err, data) { expect(err.code).to.contain('result_not_objarr') data = JSON.parse(data) + expect(data).to.be.an.object() expect(data.key).to.equal('true') done() }) @@ -109,8 +110,8 @@ describe('quartz events', function () { args: {role: role, cmd: cmdId, data: {payload_number: '#1'}} }, function (err, data) { expect(err).to.not.exist() - expect(data) - expect(data.jobId) + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data done() }) @@ -133,8 +134,8 @@ describe('quartz events', function () { args: {role: role, cmd: cmdId, data: {payload_number: '#2'}} }, function (err, data) { expect(err).to.not.exist() - expect(data) - expect(data.jobId) + expect(data).to.be.not.null() + expect(data.jobId).to.be.not.null() taskData = data done() }) From 9cb3744856f52b807711bb00afea8b3e2cf635fb Mon Sep 17 00:00:00 2001 From: Shane Lacey Date: Mon, 23 May 2016 17:24:39 +0100 Subject: [PATCH 8/8] Remove done() --- test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.js b/test/test.js index d1345c3..91f2541 100644 --- a/test/test.js +++ b/test/test.js @@ -122,7 +122,6 @@ describe('quartz events', function () { var cmdId = Uuid.v4() seneca.add({role: role, cmd: cmdId}, function (args, callback) { expect(args.data.payload_number).to.equal('#2') - done() }) seneca.ready(function () {