diff --git a/index.js b/index.js index c6100d2..2a6030d 100644 --- a/index.js +++ b/index.js @@ -106,15 +106,6 @@ MDS.prototype = { return this._sendRequest(options, callback); }, - /** - * Writes value for given key as stream - * @param {String} key - key of record - * @param {Stream} stream - streamed value - */ - writeFromStream: function (key, stream) { - return stream.pipe(request(this._getCommonWriteOptions(key))); - }, - /** * Removes value by given string key * @param {String} key - key of record @@ -133,7 +124,10 @@ MDS.prototype = { * @deprecated * @returns {Promise} */ - readP: this.read, + readP: function (key) { + this._log('"readP" method is deprecated. Use "read" instead'); + return this.read(key); + }, /** * Short alias for call write method with promise result @@ -142,7 +136,10 @@ MDS.prototype = { * @deprecated * @returns {Promise} */ - writeP: this.write, + writeP: function (key, value) { + this._log('"writeP" method is deprecated. Use "write" instead'); + return this.write(key, value); + }, /** * Short alias for call remove method with promise result @@ -150,7 +147,10 @@ MDS.prototype = { * @deprecated * @returns {Promise} */ - removeP: this.remove, + removeP: function (key) { + this._log('"removeP" method is deprecated. Use "remove" instead'); + return this.remove(key); + }, /** * Returns full url on mds storage diff --git a/test/test.js b/test/test.js index 28a7698..fb7dced 100644 --- a/test/test.js +++ b/test/test.js @@ -96,6 +96,17 @@ describe('mds-wrapper', function () { }); }); + it ('should read data by deprecated readP method', function () { + nock('http://127.0.0.1:3000') + .get('/get-my-site/key') + .reply(200, 'Hello World'); + + var mds = new MDS(getOptions()); + return mds.readP('key').then(function (data) { + data.should.equal('Hello World'); + }); + }); + it('should read value as stream as save file on filesystem', function (done) { nock('http://127.0.0.1:3000') .get('/get-my-site/key') @@ -214,6 +225,18 @@ describe('mds-wrapper', function () { }); }); + it('should write data by deprecated writeP method', function () { + nock('http://127.0.0.1:3001', 'Hello World') + .post('/upload-my-site/key') + .reply(200, 'OK'); + + var mds = new MDS(getOptions()); + return mds.writeP('key', 'Hello World').then(function (data) { + data.should.equal('OK') + }); + }); + + /* it('should write streamed data from file', function (done) { var body; nock('http://127.0.0.1:3001', 'Hello World') @@ -231,6 +254,7 @@ describe('mds-wrapper', function () { done(); }); }); + */ describe('error cases', function () { it('should return callback with error if ETIMEOUT network error occur', function (done) { @@ -320,5 +344,16 @@ describe('mds-wrapper', function () { data.should.equal('OK') }); }); + + it('should remove data by deprecated removeP method', function () { + nock('http://127.0.0.1:3001') + .get('/delete-my-site/key') + .reply(200, 'OK'); + + var mds = new MDS(getOptions()); + return mds.removeP('key').then(function (data) { + data.should.equal('OK') + }); + }); }); });