usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [24/41] git commit: removed unused functions from Usergrid.Request. stubbed out the remaining test cases for Usergrid.Client
Date Tue, 11 Feb 2014 23:21:08 GMT
removed unused functions from Usergrid.Request. stubbed out the remaining test cases for Usergrid.Client


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e104c3e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e104c3e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e104c3e9

Branch: refs/heads/master
Commit: e104c3e94f0a8616af3abed33ba23d98336120c0
Parents: a976d1a
Author: ryan bridges <rbridges@apigee.com>
Authored: Mon Feb 10 17:48:10 2014 -0500
Committer: ryan bridges <rbridges@apigee.com>
Committed: Mon Feb 10 17:48:10 2014 -0500

----------------------------------------------------------------------
 sdks/html5-javascript/lib/Usergrid.js     |  18 +---
 sdks/html5-javascript/tests/mocha/test.js | 128 ++++++++++++++++++++++++-
 sdks/html5-javascript/usergrid.js         |  17 +---
 sdks/html5-javascript/usergrid.min.js     |   4 +-
 4 files changed, 129 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e104c3e9/sdks/html5-javascript/lib/Usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/Usergrid.js b/sdks/html5-javascript/lib/Usergrid.js
index e607075..ec10de1 100644
--- a/sdks/html5-javascript/lib/Usergrid.js
+++ b/sdks/html5-javascript/lib/Usergrid.js
@@ -186,7 +186,7 @@ function doCallback(callback, params, context) {
          */
         if (!isValidUrl(this.endpoint)) {
             this.logger.error(endpoint, this.endpoint, /^https:\/\//.test(endpoint));
-            throw new UsergridError("The provided endpoint is not valid: " + this.endpoint);
+            throw new UsergridInvalidURIError("The provided endpoint is not valid: " + this.endpoint);
         }
         /* a callback to make the request */
         var request=function () {return Ajax.request(this.method, this.endpoint, this.data)}.bind(this);
@@ -205,22 +205,6 @@ function doCallback(callback, params, context) {
         return p;
     };
     Usergrid.Request.prototype= new UsergridStorable();
-    Usergrid.Request.prototype.validate=function(){
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    }
-    Usergrid.Request.prototype.prepare=function(){
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    }
-    Usergrid.Request.prototype.fire=function(){
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    }
-
     //TODO more granular handling of statusCodes
     Usergrid.Response = function (err, response) {
         var p = new Promise();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e104c3e9/sdks/html5-javascript/tests/mocha/test.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/tests/mocha/test.js b/sdks/html5-javascript/tests/mocha/test.js
index 350706c..2ecf944 100644
--- a/sdks/html5-javascript/tests/mocha/test.js
+++ b/sdks/html5-javascript/tests/mocha/test.js
@@ -94,6 +94,26 @@ describe('Usergrid Request/Response', function() {
             done();
         })
     })
+    it('should GET an array of entity data from the Usergrid.Response object',function(done){
+        var req=new Usergrid.Request("GET", dogURI, {}, null, function(err, response){
+            assert(!err, err);
+            assert(response instanceof Usergrid.Response, "Response is not and instance of
Usergrid.Response");
+            var entities=response.getEntities();
+            console.log("ENTITIES",entities);
+            assert(entities && entities.length, "Nothing was returned")
+            done();
+        })
+    })
+    it('should GET entity data from the Usergrid.Response object',function(done){
+        var req=new Usergrid.Request("GET", dogURI+'/'+dogName, {}, null, function(err, response){
+            var entity=response.getEntity();
+            console.log("ENTITY",entity);
+            assert(!err, err);
+            assert(response instanceof Usergrid.Response, "Response is not and instance of
Usergrid.Response");
+            assert(entity, "Nothing was returned")
+            done();
+        })
+    })
     it('should PUT to a URI',function(done){
         var req=new Usergrid.Request("PUT", dogURI+'/'+dogName, {}, {favorite:true}, function(err,
response){
             assert(!err, err);
@@ -108,6 +128,28 @@ describe('Usergrid Request/Response', function() {
             done();
         })
     })
+    it('should NOT allow an invalid method',function(done){
+        try{
+            var req=new Usergrid.Request("INVALID", dogURI+'/'+dogName, {}, null, function(err,
response){
+                assert(true, "Should have thrown an UsergridInvalidHTTPMethodError");
+                done();
+            })
+        }catch(e){
+            assert(e instanceof UsergridInvalidHTTPMethodError, "Error is not and instance
of UsergridInvalidHTTPMethodError");
+            done()
+        }
+    })
+    it('should NOT allow an invalid URI',function(done){
+        try{
+            var req=new Usergrid.Request("GET", "://apigee.com", {}, null, function(err,
response){
+                assert(true, "Should have thrown an UsergridInvalidURIError");
+                done();
+            })
+        }catch(e){
+            assert(e instanceof UsergridInvalidURIError, "Error is not and instance of UsergridInvalidURIError");
+            done()
+        }
+    })
     it('should return a UsergridError object on an invalid URI',function(done){
         var req=new Usergrid.Request("GET", dogURI+'/'+dogName+'zzzzz', {}, null, function(err,
response){
             assert(err, "Should have returned an error");
@@ -117,9 +159,9 @@ describe('Usergrid Request/Response', function() {
         })
     })
 });
-describe('Usergrid', function() {
+describe('Usergrid Client', function() {
 	var client = getClient();
-	describe('Usergrid CRUD', function() {
+	describe('Usergrid CRUD request', function() {
 		before(function(done) {
 			//Make sure our dog doesn't already exist
 			client.request({
@@ -223,7 +265,87 @@ describe('Usergrid', function() {
 			});
 		});
 	});
-	describe('Usergrid Entity', function() {
+    describe('Usergrid convenience methods', function(){
+        it('createEntity',function(done){
+            done();
+        })
+        it('createCollection',function(done){
+            done();
+        })
+        it('createGroup',function(done){
+            done();
+        })
+        it('buildAssetURL',function(done){
+            done();
+        })
+        it('getEntity',function(done){
+            done();
+        })
+        it('restoreEntity',function(done){
+            done();
+        })
+        it('restoreCollection',function(done){
+            done();
+        })
+        it('getFeedForUser',function(done){
+            done();
+        })
+        it('createUserActivity',function(done){
+            done();
+        })
+        it('createUserActivityWithEntity',function(done){
+            done();
+        })
+        it('set',function(done){
+            done();
+        })
+        it('get',function(done){
+            done();
+        })
+        it('setObject',function(done){
+            done();
+        })
+        it('getObject',function(done){
+            done();
+        })
+        it('setToken',function(done){
+            done();
+        })
+        it('getToken',function(done){
+            done();
+        })
+        it('signup',function(done){
+            done();
+        })
+        it('login',function(done){
+            done();
+        })
+        it('reAuthenticateLite',function(done){
+            done();
+        })
+        it('reAuthenticate',function(done){
+            done();
+        })
+        it('loginFacebook',function(done){
+            done();
+        })
+        it('getLoggedInUser',function(done){
+            done();
+        })
+        it('isLoggedIn',function(done){
+            done();
+        })
+        it('logout',function(done){
+            done();
+        })
+        it('buildCurlCall',function(done){
+            done();
+        })
+        it('getDisplayImage',function(done){
+            done();
+        })
+    });
+    describe('Usergrid Entity', function() {
 		var dog;
 		before(function(done) {
 			//Make sure our dog doesn't already exist

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e104c3e9/sdks/html5-javascript/usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/usergrid.js b/sdks/html5-javascript/usergrid.js
index 7d4bc06..38a8011 100644
--- a/sdks/html5-javascript/usergrid.js
+++ b/sdks/html5-javascript/usergrid.js
@@ -541,7 +541,7 @@ function doCallback(callback, params, context) {
          */
         if (!isValidUrl(this.endpoint)) {
             this.logger.error(endpoint, this.endpoint, /^https:\/\//.test(endpoint));
-            throw new UsergridError("The provided endpoint is not valid: " + this.endpoint);
+            throw new UsergridInvalidURIError("The provided endpoint is not valid: " + this.endpoint);
         }
         /* a callback to make the request */
         var request = function() {
@@ -563,21 +563,6 @@ function doCallback(callback, params, context) {
         return p;
     };
     Usergrid.Request.prototype = new UsergridStorable();
-    Usergrid.Request.prototype.validate = function() {
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    };
-    Usergrid.Request.prototype.prepare = function() {
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    };
-    Usergrid.Request.prototype.fire = function() {
-        var p = new Promise();
-        p.done(null, this);
-        return p;
-    };
     //TODO more granular handling of statusCodes
     Usergrid.Response = function(err, response) {
         var p = new Promise();


Mime
View raw message