From c8de4b9cb5c34f4fdb032d381faa2886b0642912 Mon Sep 17 00:00:00 2001 From: cory robinson Date: Tue, 20 Sep 2016 22:42:33 -0700 Subject: [PATCH 1/3] docs(.github/): add comments on semantic-release to PR template .md --- .github/PULL_REQUEST_TEMPLATE.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 618e220..468731b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,9 @@ Fixes # (it's a good idea to open an issue first for discussion) +> Note: This project uses `semantic-release` to auto publish npm packages on successful builds. +The commit messages must follow AngularJS Commit Msg Conventions: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.uyo6cb12dt6w + +- [ ] - My commit messages follow AngularJS Commit Msg Conventions - [ ] - If applicable, appropriate JSDoc comments were updated in source code -- [ ] - If applicable, approprate changes to js-data.io docs have been suggested ("Suggest Edits" button) +- [ ] - If applicable, appropriate changes to js-data.io docs have been suggested ("Suggest Edits" button) +- [ ] - Unit test coverage did not decrease & appropriate tests changes made From 90338c2265483383c97169e5913e053115cef8e6 Mon Sep 17 00:00:00 2001 From: cory robinson Date: Tue, 20 Sep 2016 22:44:10 -0700 Subject: [PATCH 2/3] chore(build-steps): add semantic-release package and circle.yml configs for auto npm publish --- circle.yml | 3 ++- package.json | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index 7df1a71..74c6d46 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,7 @@ general: - gh-pages machine: node: - version: 5.7.0 + version: 6 dependencies: pre: - npm install -g npm @@ -13,3 +13,4 @@ dependencies: test: post: - nyc report --reporter=lcov | codecov + - npm run semantic-release || true diff --git a/package.json b/package.json index c19e8a1..557275d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-mongodb", "description": "MongoDB adapter for js-data.", - "version": "1.0.0-rc.1", + "version": "0.0.0-semantic-release", "homepage": "https://github.com/js-data/js-data-mongodb", "repository": { "type": "git", @@ -55,7 +55,11 @@ "mocha": "mocha -t 20000 -R dot -r babel-core/register -r babel-polyfill mocha.start.js", "cover": "nyc --require babel-core/register --require babel-polyfill --cache mocha -t 20000 -R dot mocha.start.js && nyc report --reporter=html", "test": "npm run build && npm run cover", - "release": "npm test && npm run doc && repo-tools updates && repo-tools changelog && repo-tools authors" + "release": "npm test && npm run doc && repo-tools updates && repo-tools changelog && repo-tools authors", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" + }, + "release": { + "verifyConditions": "condition-circle" }, "dependencies": { "js-data-adapter": "~0.8.2", @@ -67,6 +71,8 @@ "mongodb": ">=1.3.x" }, "devDependencies": { - "js-data-repo-tools": "0.5.6" + "condition-circle": "^1.5.0", + "js-data-repo-tools": "0.5.6", + "semantic-release": "^4.3.5" } } From 1989fb9146648ba07e6f86013e6a687b54d77c2f Mon Sep 17 00:00:00 2001 From: cory robinson Date: Tue, 20 Sep 2016 23:31:04 -0700 Subject: [PATCH 3/3] test(coverage): add tests to increase coverage --- mocha.start.js | 1 + test/find.test.js | 34 ++++++++++++++++++++++++++++++++++ test/update.test.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 test/update.test.js diff --git a/mocha.start.js b/mocha.start.js index 4667152..11ea0d7 100644 --- a/mocha.start.js +++ b/mocha.start.js @@ -41,6 +41,7 @@ JSDataAdapterTests.init({ }) require('./test/find.test') +require('./test/update.test') describe('exports', function () { it('should have exports', function () { diff --git a/test/find.test.js b/test/find.test.js index 24f571a..f5404c3 100644 --- a/test/find.test.js +++ b/test/find.test.js @@ -58,4 +58,38 @@ describe('MongoDBAdapter#find', function () { assert.objectsEqual(user, { _id: id, bsonField: ObjectID.toString() }) }) }) + + it('should use orderBy array', function () { + var id + + return adapter.findAll(User, { + name: 'John' + }).then(function (users) { + assert.equal(users.length, 0) + return adapter.create(User, { _id: '1', name: 'John' }) + }).then(function (user) { + id = user._id + assert.equal(typeof id, 'string') + return adapter.findAll(User, {where: {id: id}, orderBy: ['name', 'asc']}) + }).then(function (userList) { + assert.objectsEqual(userList, [{ _id: id, name: 'John' }]) + }) + }) + + it('should use orderBy string', function () { + var id + + return adapter.findAll(User, { + name: 'John' + }).then(function (users) { + assert.equal(users.length, 0) + return adapter.create(User, { _id: '1', name: 'John' }) + }).then(function (user) { + id = user._id + assert.equal(typeof id, 'string') + return adapter.findAll(User, {where: {id: id}, orderBy: 'name'}) + }).then(function (userList) { + assert.objectsEqual(userList, [{ _id: id, name: 'John' }]) + }) + }) }) diff --git a/test/update.test.js b/test/update.test.js new file mode 100644 index 0000000..0c07dc7 --- /dev/null +++ b/test/update.test.js @@ -0,0 +1,28 @@ +describe('MongoDBAdapter#find', function () { + var adapter + + // create a record to test update against + before(function () { + var id + + this.$$adapter.findAll(this.$$User, { + name: 'John' + }).then(function (users) { + assert.equal(users.length, 0) + return this.$$adapter.create(this.$$User, {name: 'John'}) + }).then(function (user) { + id = user._id + return this.$$adapter.find(this.$$User, id.toString()) + }).then(function (user) { + assert.objectsEqual(user, {_id: id, name: 'John'}) + }) + }) + + beforeEach(function () { + adapter = this.$$adapter + }) + + it('should not support updateMany', function () { + return assert.throws(adapter.updateMany) + }) +})