From 094a640e58f32ad3df561e52502ac46f59aaaf2f Mon Sep 17 00:00:00 2001 From: Francisco Baio Dias Date: Sat, 27 Feb 2016 14:37:45 +0000 Subject: [PATCH 1/3] Auto set json and bool flags on config.set --- src/api/config.js | 9 ++++ test/api/config.spec.js | 94 +++++++++++++++++++++++++++++++++-------- 2 files changed, 85 insertions(+), 18 deletions(-) diff --git a/src/api/config.js b/src/api/config.js index 3ba502084..582362bb6 100644 --- a/src/api/config.js +++ b/src/api/config.js @@ -10,6 +10,15 @@ module.exports = (send) => { cb = opts opts = {} } + + if (typeof (value) === 'object') { + value = JSON.stringify(value) + opts = { json: true } + } else if (typeof (value) === 'boolean') { + value = value.toString() + opts = { bool: true } + } + return send('config', [key, value], opts, null, cb) }, show (cb) { diff --git a/test/api/config.spec.js b/test/api/config.spec.js index d8029e6f3..d70795d63 100644 --- a/test/api/config.spec.js +++ b/test/api/config.spec.js @@ -3,16 +3,46 @@ const path = require('path') describe('.config', () => { - it('.config.{set, get}', (done) => { - const confKey = 'arbitraryKey' - const confVal = 'arbitraryVal' + describe('.config.{set, get}', () => { + it('string', (done) => { + const confKey = 'arbitraryKey' + const confVal = 'arbitraryVal' - apiClients['a'].config.set(confKey, confVal, (err, res) => { - expect(err).to.not.exist - apiClients['a'].config.get(confKey, (err, res) => { + apiClients['a'].config.set(confKey, confVal, (err, res) => { + expect(err).to.not.exist + apiClients['a'].config.get(confKey, (err, res) => { + expect(err).to.not.exist + expect(res).to.have.a.property('Value', confVal) + done() + }) + }) + }) + + it('bool', (done) => { + const confKey = 'otherKey' + const confVal = true + + apiClients['a'].config.set(confKey, confVal, (err, res) => { expect(err).to.not.exist - expect(res).to.have.a.property('Value', confVal) - done() + apiClients['a'].config.get(confKey, (err, res) => { + expect(err).to.not.exist + expect(res.Value).to.deep.equal(confVal) + done() + }) + }) + }) + + it('json', (done) => { + const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin' + const confVal = ['http://example.io'] + + apiClients['a'].config.set(confKey, confVal, (err, res) => { + expect(err).to.not.exist + apiClients['a'].config.get(confKey, (err, res) => { + expect(err).to.not.exist + expect(res.Value).to.deep.equal(confVal) + done() + }) }) }) }) @@ -38,17 +68,45 @@ describe('.config', () => { }) describe('promise', () => { - it('.config.{set, get}', () => { - const confKey = 'arbitraryKey' - const confVal = 'arbitraryVal' + describe('.config.{set, get}', () => { + it('string', () => { + const confKey = 'arbitraryKey' + const confVal = 'arbitraryVal' - return apiClients['a'].config.set(confKey, confVal) - .then((res) => { - return apiClients['a'].config.get(confKey) - }) - .then((res) => { - expect(res).to.have.a.property('Value', confVal) - }) + return apiClients['a'].config.set(confKey, confVal) + .then((res) => { + return apiClients['a'].config.get(confKey) + }) + .then((res) => { + expect(res).to.have.a.property('Value', confVal) + }) + }) + + it('bool', () => { + const confKey = 'otherKey' + const confVal = true + + return apiClients['a'].config.set(confKey, confVal) + .then((res) => { + return apiClients['a'].config.get(confKey) + }) + .then((res) => { + expect(res.Value).to.deep.equal(confVal) + }) + }) + + it('json', () => { + const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin' + const confVal = ['http://example.com'] + + return apiClients['a'].config.set(confKey, confVal) + .then((res) => { + return apiClients['a'].config.get(confKey) + }) + .then((res) => { + expect(res.Value).to.deep.equal(confVal) + }) + }) }) it('.config.show', () => { From 8879ecc7146d6d5ef97fbd26a3270a7efb8dd473 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Thu, 3 Mar 2016 02:34:44 +0100 Subject: [PATCH 2/3] chore(package): update glob-stream to version 5.3.2 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 243371072..1064d6441 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "eslint-config-standard": "^5.1.0", "eslint-plugin-promise": "^1.0.8", "eslint-plugin-standard": "^1.3.1", - "glob-stream": "5.3.1", + "glob-stream": "5.3.2", "gulp": "^3.9.0", "gulp-bump": "^1.0.0", "gulp-eslint": "^2.0.0-rc-3", From 9691741fde0b910c54e80d611ec57fe06a2de740 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Wed, 16 Mar 2016 19:39:00 +0100 Subject: [PATCH 3/3] chore(package): update gulp-bump to version 2.0.1 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1064d6441..270ef28b0 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "eslint-plugin-standard": "^1.3.1", "glob-stream": "5.3.2", "gulp": "^3.9.0", - "gulp-bump": "^1.0.0", + "gulp-bump": "^2.0.1", "gulp-eslint": "^2.0.0-rc-3", "gulp-filter": "^4.0.0", "gulp-git": "^1.6.0",