Permalink
Browse files

bump the version. addded tests file. fixed broken tests, added autopa…

…ginate option. Moved the interfaces into the config so both client and provider can use it.
  • Loading branch information...
AnalogJ committed Jul 26, 2014
1 parent 4acdeb7 commit ecd360af5fc7edca31a10bf06d100406b1f27bd8
View
@@ -0,0 +1,8 @@
MOCHA_OPTS= --check-leaks
REPORTER = dot
test:test-integration
test-integration:
@NODE_ENV=test mocha test
View
@@ -49,8 +49,9 @@ FileFog.prototype.use = function(name, provider_definition,config) {
throw new Error("Provider name is missing")
}
config = extend(true, provider_definition.config, config);
config = extend(true, {interfaces:provider_definition.provider.prototype.interfaces },provider_definition.config, config);
delete provider_definition.config;
delete provider_definition.provider.prototype.interfaces;
this._provider_definitions[name] = {
classes:provider_definition,
@@ -31,7 +31,7 @@ module.exports = function(name,base_client,transform, provider_config, credentia
this.name = name;
this.config = provider_config || {};
this.credentials = credentials || {};
this.filefog_options = extend(true, {transform:true, include_raw:true}, filefog_options || {});
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true}, filefog_options || {});
this._transform = transform;
base_client.call(this);
@@ -14,7 +14,6 @@ var q = require("q");
module.exports = function(name, classes, config,filefog_options){
var base_provider =classes.provider;
/**
* Wraps the provided base Provider constructor and provides instance variables.
* @constructor ProviderWrapper
@@ -29,7 +28,7 @@ module.exports = function(name, classes, config,filefog_options){
this.name = name;
this.config = config || {};
this._transform = transform;
this.filefog_options = extend(true, {transform:true, include_raw:true}, filefog_options || {});
this.filefog_options = extend(true, {transform:true, include_raw:true, auto_paginate:true}, filefog_options || {});
base_provider.call(this, name);
}
util.inherits(ProviderWrapper, base_provider);
@@ -65,7 +64,7 @@ module.exports = function(name, classes, config,filefog_options){
return q.when(ClientWrapper(this.name,classes.client, classes.transform, this.config, credentials,default_filefog_options))
};
if(base_provider.prototype.interfaces.indexOf("oauth") != -1){
if(config.interfaces.indexOf("oauth") != -1){
ProviderWrapper.prototype._methodWrapper = function(method, args, filefog_options){
//TODO: pop the filefog variable off the args object, it should only be used to configure Filefog.
View
@@ -2,7 +2,7 @@
"author": "Jason Kulatunga",
"name": "filefog",
"description": "Cloud Storage API Wrapper supporting Box, Dropbox, Skydrive, Google Drive",
"version": "0.0.16",
"version": "0.0.17",
"repository": {
"url": "https://github.com/filefog/filefog.git"
},
@@ -19,5 +19,8 @@
"optionalDependencies": {},
"engines": {
"node": "*"
},
"scripts": {
"test": "make test"
}
}
View
@@ -69,23 +69,26 @@ describe('#use()', function () {
describe("#provider()",function(){
var provider
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var definition = {
/**
* Description
* @method provider
* @return
*/
provider : function(){},
provider : Provider,
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){}
client: function(){},
config: {}
}
provider = FileFog.use("empty",definition)
provider = FileFog.use("empty",definition,{})
});
it("should throw an error if the provider name is not valid", function(){
@@ -3,21 +3,24 @@ var FileFog = require('../../lib/main.js');
describe("ClientWrapper",function(){
var clientPromise;
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var base_classes = {
/**
* Description
* @method provider
* @return
*/
provider : function(){},
provider : Provider,
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){}
client: function(){},
config: {}
}
FileFog.use("empty",base_classes);
clientPromise = FileFog.client("empty");
@@ -3,21 +3,24 @@ var FileFog = require('../../lib/main.js');
describe("ProviderWrapper",function(){
var provider;
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var base_classes = {
/**
* Description
* @method provider
* @return
*/
provider : function(){},
provider : Provider,
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){}
client: function(){},
config: {}
}
FileFog.use("empty",base_classes);
provider = FileFog.provider("empty");
@@ -45,9 +48,9 @@ describe("ProviderWrapper",function(){
describe("#setConfig()", function(){
it("should extend existing values", function(){
provider.setConfig({test:"test", test2:"test2"})
provider.setConfig({ test:"test", test2:"test2" })
provider.getConfig().test.should.eql("test");
provider.setConfig({test:"new_test"})
provider.setConfig({ test:"new_test" })
provider.getConfig().test.should.eql("new_test");
})

0 comments on commit ecd360a

Please sign in to comment.