Permalink
Browse files

more updates

  • Loading branch information...
mwawrusch committed Jul 28, 2011
1 parent 91b9c8a commit c90fccb3533b35212da87e3d60d34b1895e86399
Showing with 137 additions and 7 deletions.
  1. +12 −4 lib/nodester/client.rb
  2. +105 −1 spec/client_spec.rb
  3. +5 −2 spec/fakeweb_helper.rb
  4. +5 −0 spec/stubs/get_app
  5. +5 −0 spec/stubs/get_apps
  6. +5 −0 spec/stubs/post_app
View
@@ -77,7 +77,8 @@ def platform_delete_user()
# appname (required). The name of the app.
# start (required). The file to start, for example server.js.
# Returns:
- # status : "success" |
+ # status : "success" | "failure"
+ # message : "some text" ==> Only if failure
# port : 12345
# gitrepo : 'git@nodester.com:/node/git/mwawrusch/blah.git'
# start : "the value of start, for example servre.js"
@@ -96,14 +97,21 @@ def update_app(appname,opts = {})
handle_result self.class.put('/app', options)
end
+ def start_stop_app(appname,running = true)
+
+ options={:body=> {:appname => appname, :running=>start}, :basic_auth => @auth}
+ handle_result self.class.put('/app', options)
+ end
+
+
def delete_app(appname)
options={:body => {:appname => appname}, :basic_auth => @auth}
handle_result self.class.delete('/app', options)
end
def app(appname)
- options={:body => {:appname => appname},:basic_auth => @auth}
- handle_result self.class.get('/app', options)
+ options={:body => {},:basic_auth => @auth}
+ handle_result self.class.get("/app/#{appname}", options)
end
# Get a list of all apps.
@@ -119,7 +127,7 @@ def app(appname)
# gitrepo : 'git@nodester.com:/node/git/mwawrusch/2914-2295037e88fed947a9b3b994171c5a9e.git", "running"=>false, "pid"=>"unknown"}
def apps()
options={:basic_auth => @auth}
- handle_result self.class.get('/apps/', options)
+ handle_result self.class.get('/apps', options)
end
View
@@ -9,7 +9,7 @@
context "when invoking platform_coupon_request" do
- it "should return a status" do
+ it "should be a success" do
res = @client.platform_coupon_request "arthur@dent.com"
res['status'].start_with?('success').should == true
end
@@ -24,4 +24,108 @@
end
end
+ # Need testing:
+ #platform_create_user
+ #update_user
+ #platform_delete_user
+
+ context "when invoking create_app" do
+ it "should create an app" do
+ res = @client.create_app "testapp","server.js"
+ res['status'].should == "success"
+ res['port'].should > 0
+ res['gitrepo'].start_with?('git@nodester.com:/node/git/').should == true
+ res['start'].should == 'server.js'
+ res['running'].should == false
+ res['pid'].should == 'unknown'
+
+ end
+ end
+
+=begin
+ context "when invoking update_app" do
+ it "should update an app" do
+ res = @client.update_app
+ end
+ end
+
+ context "when invoking start_stop_app" do
+ it "should start an app" do
+ res = @client.start_stop_app('testapp',true)
+ end
+ end
+
+ context "when invoking delete_app" do
+ it "should delete an app" do
+ res = @client.delete_app
+ end
+ end
+=end
+
+ context "when invoking app" do
+ it "should return app info" do
+ res = @client.app 'a1234'
+ res['status'].should == "success"
+ res['port'].should > 0
+ res['gitrepo'].start_with?('git@nodester.com:/node/git/').should == true
+ res['start'].should == 'server.js'
+ res['running'].should == false
+ res['pid'].should == 'unknown'
+
+ end
+ end
+
+ context "when invoking apps" do
+ it "should return a list of apps" do
+ res = @client.apps
+ res.length.should == 2
+ res[0]['name'].should == 'a1234'
+ end
+ end
+
+=begin
+ context "when invoking update_env" do
+ it "should set an env value" do
+ res = @client.update_env
+ end
+ end
+
+ context "when invoking delete_env" do
+ it "should remove an env value" do
+ res = @client.delete_env
+ end
+ end
+
+ context "when invoking env" do
+ it "should return an env value" do
+ res = @client.env
+ end
+ end
+
+ context "when invoking update_npm" do
+ it "should perform an op against the npm" do
+ res = @client.update_npm
+ end
+ end
+
+
+ context "when invoking create_appdomain" do
+ it "should create an app domain" do
+ res = @client.create_appdomain
+ end
+ end
+
+ context "when invoking delete_appdomain" do
+ it "should delete an app domain" do
+ res = @client.delete_appdomain
+ end
+ end
+
+ context "when invoking appdomains" do
+ it "should list all available appdomains" do
+ res = @client.update_npm
+ end
+ end
+=end
+
end
View
@@ -13,11 +13,14 @@ def fake_it_all
{
# GET URLs
:get => {
- 'http://nodester.com/status' => 'platform_get_status'
+ 'http://nodester.com/status' => 'platform_get_status',
+ 'http://arthur:dent@api.nodester.com/apps' => 'get_apps',
+ %r|http://arthur:dent@api.nodester.com/app/[a-zA-Z0-0]+| => 'get_app'
},
# POST URLs
:post => {
- 'http://nodester.com/coupon' => 'platform_post_coupon'
+ 'http://nodester.com/coupon' => 'platform_post_coupon',
+ 'http://arthur:dent@api.nodester.com/app' => 'post_app'
},
# PUT URLs
:put => {
View
@@ -0,0 +1,5 @@
+HTTP/1.1 200 OK
+Status: 200
+Content-Type: application/json; charset=utf-8
+
+{"status":"success","port":11092,"gitrepo":"git@nodester.com:/node/git/mwawrusch/2939-bf58ab1dd19cc93cc4427bb920c0ff4b.git","start":"server.js","running":false,"pid":"unknown"}
View
@@ -0,0 +1,5 @@
+HTTP/1.1 200 OK
+Status: 200
+Content-Type: application/json; charset=utf-8
+
+[{"name":"a1234","port":11092,"gitrepo":"git@nodester.com:/node/git/mwawrusch/2939-bf58ab1dd19cc93cc4427bb920c0ff4b.git","running":false,"pid":"unknown"},{"name":"testxyz123","port":11067,"gitrepo":"git@nodester.com:/node/git/mwawrusch/2914-2295037e88fed947a9b3b994171c5a9e.git","running":false,"pid":"unknown"}]
View
@@ -0,0 +1,5 @@
+HTTP/1.1 200 OK
+Status: 200
+Content-Type: application/json; charset=utf-8
+
+{"status":"success","port":11092,"gitrepo":"git@nodester.com:/node/git/mwawrusch/2939-bf58ab1dd19cc93cc4427bb920c0ff4b.git","start":"server.js","running":false,"pid":"unknown"}

0 comments on commit c90fccb

Please sign in to comment.