cloudfoundry-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +12 -0
  4. data/.yardopts +9 -0
  5. data/CHANGELOG.md +6 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.md +122 -0
  9. data/Rakefile +28 -0
  10. data/cloudfoundry.gemspec +29 -0
  11. data/lib/cloudfoundry.rb +34 -0
  12. data/lib/cloudfoundry/client.rb +93 -0
  13. data/lib/cloudfoundry/client/apps.rb +192 -0
  14. data/lib/cloudfoundry/client/info.rb +29 -0
  15. data/lib/cloudfoundry/client/request.rb +89 -0
  16. data/lib/cloudfoundry/client/resources.rb +16 -0
  17. data/lib/cloudfoundry/client/response.rb +68 -0
  18. data/lib/cloudfoundry/client/services.rb +122 -0
  19. data/lib/cloudfoundry/client/users.rb +121 -0
  20. data/lib/cloudfoundry/constants.rb +30 -0
  21. data/lib/cloudfoundry/exception.rb +24 -0
  22. data/lib/cloudfoundry/version.rb +27 -0
  23. data/spec/client/apps_spec.rb +423 -0
  24. data/spec/client/info_spec.rb +92 -0
  25. data/spec/client/resources_spec.rb +52 -0
  26. data/spec/client/services_spec.rb +230 -0
  27. data/spec/client/users_spec.rb +367 -0
  28. data/spec/client_spec.rb +110 -0
  29. data/spec/cloudfoundry_spec.rb +62 -0
  30. data/spec/fixtures/admin_logged/client.yml +85 -0
  31. data/spec/fixtures/admin_logged/users.yml +363 -0
  32. data/spec/fixtures/admin_logged/users_create_action.yml +36 -0
  33. data/spec/fixtures/admin_logged/users_proxy_action.yml +46 -0
  34. data/spec/fixtures/admin_logged/users_proxy_nouser_action.yml +44 -0
  35. data/spec/fixtures/admin_logged/users_unproxy_action.yml +44 -0
  36. data/spec/fixtures/app.js +16 -0
  37. data/spec/fixtures/app.zip +0 -0
  38. data/spec/fixtures/client.yml +151 -0
  39. data/spec/fixtures/client_invalid.yml +85 -0
  40. data/spec/fixtures/cloudfoundry.yml +124 -0
  41. data/spec/fixtures/cloudfoundry_vs_client.yml +159 -0
  42. data/spec/fixtures/no_logged/apps.yml +42 -0
  43. data/spec/fixtures/no_logged/client.yml +42 -0
  44. data/spec/fixtures/no_logged/info.yml +81 -0
  45. data/spec/fixtures/no_logged/resources.yml +42 -0
  46. data/spec/fixtures/no_logged/services.yml +42 -0
  47. data/spec/fixtures/no_logged/users.yml +108 -0
  48. data/spec/fixtures/no_logged/users_login_action.yml +81 -0
  49. data/spec/fixtures/no_logged/users_proxy_action.yml +42 -0
  50. data/spec/fixtures/no_logged/users_unproxy_action.yml +42 -0
  51. data/spec/fixtures/user_logged/apps.yml +828 -0
  52. data/spec/fixtures/user_logged/apps_create_action.yml +42 -0
  53. data/spec/fixtures/user_logged/apps_directory_action.yml +48 -0
  54. data/spec/fixtures/user_logged/apps_download_action.yml +55 -0
  55. data/spec/fixtures/user_logged/apps_file_action.yml +54 -0
  56. data/spec/fixtures/user_logged/apps_start_action.yml +81 -0
  57. data/spec/fixtures/user_logged/apps_stats_action.yml +44 -0
  58. data/spec/fixtures/user_logged/apps_update_info_action.yml +44 -0
  59. data/spec/fixtures/user_logged/apps_upload_filename_action.yml +62 -0
  60. data/spec/fixtures/user_logged/apps_upload_zipfile_action.yml +62 -0
  61. data/spec/fixtures/user_logged/client.yml +85 -0
  62. data/spec/fixtures/user_logged/info.yml +126 -0
  63. data/spec/fixtures/user_logged/resources.yml +44 -0
  64. data/spec/fixtures/user_logged/resources_check_action.yml +42 -0
  65. data/spec/fixtures/user_logged/services.yml +354 -0
  66. data/spec/fixtures/user_logged/services_bind_action.yml +161 -0
  67. data/spec/fixtures/user_logged/services_create_action.yml +83 -0
  68. data/spec/fixtures/user_logged/services_unbind_action.yml +122 -0
  69. data/spec/fixtures/user_logged/services_unbind_fail_action.yml +122 -0
  70. data/spec/fixtures/user_logged/users.yml +299 -0
  71. data/spec/fixtures/user_logged/users_proxy_action.yml +44 -0
  72. data/spec/fixtures/user_logged/users_unproxy_action.yml +44 -0
  73. data/spec/spec_helper.rb +29 -0
  74. data/spec/support/cf_connection_helper.rb +26 -0
  75. data/spec/support/vcr.rb +8 -0
  76. metadata +235 -0
@@ -0,0 +1,30 @@
1
+ module CloudFoundry
2
+ class Client
3
+ # The HTTP connection adapter that will be used to connect if none is set.
4
+ DEFAULT_ADAPTER = :net_http
5
+
6
+ # Default CloudFoundry API Target URL.
7
+ DEFAULT_TARGET = "http://api.vcap.me"
8
+
9
+ # CloudFoundry API Info Path.
10
+ CLOUD_INFO_PATH = "/info"
11
+
12
+ # CloudFoundry API System Services Info Path.
13
+ CLOUD_SERVICES_INFO_PATH = "/info/services"
14
+
15
+ # CloudFoundry API Runtimes Info Path.
16
+ CLOUD_RUNTIMES_INFO_PATH = "/info/runtimes"
17
+
18
+ # CloudFoundry API Applications Path.
19
+ APPS_PATH = "/apps"
20
+
21
+ # CloudFoundry API Resources Path.
22
+ RESOURCES_PATH = "/resources"
23
+
24
+ # CloudFoundry API Services Path.
25
+ SERVICES_PATH = "/services"
26
+
27
+ # CloudFoundry API Users Path.
28
+ USERS_PATH = "/users"
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module CloudFoundry
2
+ class Client
3
+ # CloudFoundry::Client Exceptions.
4
+ module Exception
5
+ # CloudFoundry Client Exception: Authorization Error.
6
+ class AuthError < RuntimeError; end
7
+ # CloudFoundry Client Exception: Bad Parameters.
8
+ class BadParams < RuntimeError; end
9
+ # CloudFoundry Client Exception: Bad Response Received.
10
+ class BadResponse < RuntimeError; end
11
+
12
+ # CloudFoundry Cloud Exception: Bad Request.
13
+ class BadRequest < RuntimeError; end
14
+ # CloudFoundry Cloud Exception: Forbidden.
15
+ class Forbidden < RuntimeError; end
16
+ # CloudFoundry Cloud Exception: Not Found.
17
+ class NotFound < RuntimeError; end
18
+ # CloudFoundry Cloud Exception: Server Error.
19
+ class ServerError < RuntimeError; end
20
+ # CloudFoundry Cloud Exception: Bad Gateway.
21
+ class BadGateway < RuntimeError; end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ module CloudFoundry
2
+ class Client
3
+
4
+ # Major CloudFoundry::Client Version.
5
+ def self.major
6
+ 0
7
+ end
8
+
9
+ # Minor CloudFoundry::Client Version.
10
+ def self.minor
11
+ 1
12
+ end
13
+
14
+ # Patch CloudFoundry::Client Version.
15
+ def self.patch
16
+ 0
17
+ end
18
+
19
+ # Pre CloudFoundry::Client Version.
20
+ def self.pre
21
+ nil
22
+ end
23
+
24
+ # CloudFoundry::Client Version.
25
+ VERSION = [major, minor, patch, pre].compact.join(".")
26
+ end
27
+ end
@@ -0,0 +1,423 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "Cloudfoundry::Client::Apps" do
4
+ include CfConnectionHelper
5
+
6
+ context "without a user logged in" do
7
+ before(:all) do
8
+ VCR.use_cassette("no_logged/client", :record => :new_episodes) do
9
+ @cf_client = client_no_logged()
10
+ end
11
+ end
12
+
13
+ use_vcr_cassette "no_logged/apps", :record => :new_episodes
14
+
15
+ it "should raise an AuthError exception when creating an application" do
16
+ expect {
17
+ created = @cf_client.create_app("newapp")
18
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
19
+ end
20
+
21
+ it "should raise an AuthError exception when listing all applications at target cloud" do
22
+ expect {
23
+ apps = @cf_client.list_apps()
24
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
25
+ end
26
+
27
+ it "should raise an AuthError exception when retrieving basic application information from target cloud" do
28
+ expect {
29
+ app_info = @cf_client.app_info("newapp")
30
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
31
+ end
32
+
33
+ it "should raise an AuthError exception when retrieving application instances information from target cloud" do
34
+ expect {
35
+ app_instances = @cf_client.app_instances("newapp")
36
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
37
+ end
38
+
39
+ it "should raise an AuthError exception when retrieving application stats information from target cloud" do
40
+ expect {
41
+ app_stats = @cf_client.app_stats("newapp")
42
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
43
+ end
44
+
45
+ it "should raise an AuthError exception when retrieving application crashes information from target cloud" do
46
+ expect {
47
+ app_crashes = @cf_client.app_crashes("newapp")
48
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
49
+ end
50
+
51
+ it "should raise an AuthError exception when retrieving application files information from target cloud" do
52
+ expect {
53
+ app_files = @cf_client.app_files("newapp")
54
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
55
+ end
56
+
57
+ it "should raise an AuthError exception when updating an application at target cloud" do
58
+ expect {
59
+ updated = @cf_client.update_app("newapp")
60
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
61
+ end
62
+
63
+ it "should raise an AuthError exception when retrieving application update status information from target cloud" do
64
+ expect {
65
+ update_info = @cf_client.update_app_info("newapp")
66
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
67
+ end
68
+
69
+ it "should raise an AuthError exception when uploading application bits to target cloud" do
70
+ expect {
71
+ appfile = spec_fixture("app.zip")
72
+ upload = @cf_client.upload_app("newapp", appfile)
73
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
74
+ end
75
+
76
+ it "should raise an AuthError exception when application bits at target cloud" do
77
+ expect {
78
+ appbits = @cf_client.download_app("newapp")
79
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
80
+ end
81
+
82
+ it "should raise an AuthError exception when deleting an application at target cloud" do
83
+ expect {
84
+ deleted = @cf_client.delete_app("newapp")
85
+ }.to raise_exception(CloudFoundry::Client::Exception::AuthError)
86
+ end
87
+ end
88
+
89
+ context "with a user logged in" do
90
+ before(:all) do
91
+ VCR.use_cassette("user_logged/client", :record => :new_episodes) do
92
+ @cf_client = client_user_logged()
93
+ end
94
+ end
95
+
96
+ use_vcr_cassette "user_logged/apps", :record => :new_episodes
97
+
98
+ it "should raise a BadParams exception when creating an application with a blank application name" do
99
+ expect {
100
+ created = @cf_client.create_app("")
101
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
102
+ end
103
+
104
+ it "should raise a BadParams exception when creating an application with no manifest" do
105
+ expect {
106
+ created = @cf_client.create_app("newapp")
107
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
108
+ end
109
+
110
+ it "should raise a BadRequest exception when creating an application with an invalid manifest" do
111
+ expect {
112
+ manifest = {
113
+ :name => "newapp",
114
+ }
115
+ created = @cf_client.create_app("newapp", manifest)
116
+ }.to raise_exception(CloudFoundry::Client::Exception::BadRequest)
117
+ end
118
+
119
+ it "should return true if a new application is created at target cloud" do
120
+ VCR.use_cassette("user_logged/apps_create_action", :record => :new_episodes, :exclusive => true) do
121
+ manifest = {
122
+ :name => "newapp",
123
+ :uris => ["newapp.vcap.me"],
124
+ :instances => 1,
125
+ :staging => {:model => "node"},
126
+ :resources => {:memory => 64}
127
+ }
128
+ created = @cf_client.create_app("newapp", manifest)
129
+ created.should be_true
130
+ end
131
+ end
132
+
133
+ it "should get a proper list of apps at target cloud" do
134
+ apps = @cf_client.list_apps()
135
+ apps.should have_at_least(1).items
136
+ app_info = apps.first
137
+ app_info.should have_key :name
138
+ app_info.should have_key :staging
139
+ app_info.should have_key :uris
140
+ app_info.should have_key :instances
141
+ app_info.should have_key :runningInstances
142
+ app_info.should have_key :resources
143
+ app_info.should have_key :state
144
+ app_info.should have_key :services
145
+ app_info.should have_key :version
146
+ app_info.should have_key :env
147
+ app_info.should have_key :meta
148
+ end
149
+
150
+ it "should raise an BadParams exception when retrieving basic information with blank application name" do
151
+ expect {
152
+ app_info = @cf_client.app_info("")
153
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
154
+ end
155
+
156
+ it "should raise an NotFound exception when retrieving basic information for an application that does not exists at target cloud" do
157
+ expect {
158
+ app_info = @cf_client.app_info("noapp")
159
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
160
+ end
161
+
162
+ it "should properly get basic application information from target cloud" do
163
+ app_info = @cf_client.app_info("newapp")
164
+ app_info.should have_key :name
165
+ app_info.should have_key :staging
166
+ app_info.should have_key :uris
167
+ app_info.should have_key :instances
168
+ app_info.should have_key :runningInstances
169
+ app_info.should have_key :resources
170
+ app_info.should have_key :state
171
+ app_info.should have_key :services
172
+ app_info.should have_key :version
173
+ app_info.should have_key :env
174
+ app_info.should have_key :meta
175
+ end
176
+
177
+ it "should raise an BadParams exception when retrieving instances information with blank application name" do
178
+ expect {
179
+ app_instances = @cf_client.app_instances("")
180
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
181
+ end
182
+
183
+ it "should raise an NotFound exception when retrieving instances information for an application that does not exists at target cloud" do
184
+ expect {
185
+ app_instances = @cf_client.app_instances("noapp")
186
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
187
+ end
188
+
189
+ it "should properly get application instances information from target cloud" do
190
+ app_instances = @cf_client.app_instances("newapp")
191
+ app_instances.should have_key :instances
192
+ end
193
+
194
+ it "should raise an BadParams exception when retrieving stats information with blank application name" do
195
+ expect {
196
+ app_stats = @cf_client.app_stats("")
197
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
198
+ end
199
+
200
+ it "should raise an NotFound exception when retrieving stats information for an application that does not exists at target cloud" do
201
+ expect {
202
+ app_stats = @cf_client.app_stats("noapp")
203
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
204
+ end
205
+
206
+ it "should properly get empty application stats information from target cloud" do
207
+ app_stats = @cf_client.app_stats("newapp")
208
+ app_stats.should be_empty
209
+ end
210
+
211
+ it "should raise an BadParams exception when retrieving crashes information with blank application name" do
212
+ expect {
213
+ app_crashes = @cf_client.app_crashes("")
214
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
215
+ end
216
+
217
+ it "should raise an NotFound exception when retrieving crashes information for an application that does not exists at target cloud" do
218
+ expect {
219
+ app_crashes = @cf_client.app_crashes("noapp")
220
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
221
+ end
222
+
223
+ it "should properly get application crashes information from target cloud" do
224
+ app_crashes = @cf_client.app_crashes("newapp")
225
+ app_crashes.should have_key :crashes
226
+ end
227
+
228
+ it "should raise an BadParams exception when retrieving files information with blank application name" do
229
+ expect {
230
+ app_files = @cf_client.app_files("")
231
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
232
+ end
233
+
234
+ it "should raise an NotFound exception when retrieving files information for an application that does not exists at target cloud" do
235
+ expect {
236
+ app_files = @cf_client.app_files("noapp")
237
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
238
+ end
239
+
240
+ it "should raise an BadRequest exception when retrieving files information for an application without bits at target cloud" do
241
+ expect {
242
+ app_files = @cf_client.app_files("newapp")
243
+ }.to raise_exception(CloudFoundry::Client::Exception::BadRequest)
244
+ end
245
+
246
+ it "should raise a BadParams exception when updating an application with a blank name" do
247
+ expect {
248
+ updated = @cf_client.update_app("")
249
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
250
+ end
251
+
252
+ it "should raise a BadParams exception when updating an application with no manifest" do
253
+ expect {
254
+ updated = @cf_client.update_app("newapp")
255
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
256
+ end
257
+
258
+ it "should raise a NotFound exception when updating an application that does not exists at target cloud" do
259
+ expect {
260
+ manifest = {
261
+ :name => "noapp",
262
+ }
263
+ updated = @cf_client.update_app("noapp", manifest)
264
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
265
+ end
266
+
267
+ it "should return true if an application is updated at target cloud" do
268
+ app_info = @cf_client.app_info("newapp")
269
+ app_info[:instances] = 2
270
+ updated = @cf_client.update_app("newapp", app_info)
271
+ updated.should be_true
272
+ end
273
+
274
+ it "should raise a BadParams exception when retrieving update status information with a blank name" do
275
+ expect {
276
+ update_info = @cf_client.update_app_info("")
277
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
278
+ end
279
+
280
+ it "should raise a NotFound exception when retrieving application update status information for an application that does not exists at target cloud" do
281
+ expect {
282
+ update_info = @cf_client.update_app_info("noapp")
283
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
284
+ end
285
+
286
+ it "should raise a BadParams exception when uploading application bits with a blank name" do
287
+ expect {
288
+ upload = @cf_client.upload_app("", nil)
289
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
290
+ end
291
+
292
+ it "should raise a BadParams exception when uploading application bits with a blank zipfile" do
293
+ expect {
294
+ upload = @cf_client.upload_app("newapp", nil)
295
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
296
+ end
297
+
298
+ it "should raise a BadParams exception when uploading application bits with an invalid zipfile" do
299
+ expect {
300
+ upload = @cf_client.upload_app("newapp", "fakefile")
301
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
302
+ end
303
+
304
+ it "should raise a NotFound exception when uploading application bits for an application that does not exists at target cloud" do
305
+ expect {
306
+ appfile = spec_fixture("app.zip")
307
+ upload = @cf_client.upload_app("noapp", appfile)
308
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
309
+ end
310
+
311
+ it "should raise a BadParams exception when downloading application bits with a blank name" do
312
+ expect {
313
+ appbits = @cf_client.download_app("")
314
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
315
+ end
316
+
317
+ it "should raise a NotFound exception when downloading application bits for an application that does not exists at target cloud" do
318
+ expect {
319
+ appbits = @cf_client.download_app("noapp")
320
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
321
+ end
322
+
323
+ it "should raise a NotFound exception when downloading application bits for an application without bits at target cloud" do
324
+ expect {
325
+ appbits = @cf_client.download_app("newapp")
326
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
327
+ end
328
+
329
+ it "should return true if application bits passed as filename are uploaded to the target cloud" do
330
+ VCR.use_cassette("user_logged/apps_upload_filename_action", :record => :new_episodes, :exclusive => true) do
331
+ filename = spec_fixture("app.zip")
332
+ upload = @cf_client.upload_app("newapp", filename)
333
+ upload.should be_true
334
+ end
335
+ end
336
+
337
+ it "should return true if application bits passed as file are uploaded to the target cloud" do
338
+ VCR.use_cassette("user_logged/apps_upload_zipfile_action", :record => :new_episodes, :exclusive => true) do
339
+ filename = spec_fixture("app.zip")
340
+ appfile = File.new(filename, "rb")
341
+ upload = @cf_client.upload_app("newapp", appfile)
342
+ upload.should be_true
343
+ end
344
+ end
345
+
346
+ it "should return true if an application is started at target cloud" do
347
+ VCR.use_cassette("user_logged/apps_start_action", :record => :new_episodes, :exclusive => true) do
348
+ app_info = @cf_client.app_info("newapp")
349
+ app_info[:state] = "STARTED"
350
+ updated = @cf_client.update_app("newapp", app_info)
351
+ updated.should be_true
352
+ end
353
+ end
354
+
355
+ it "should properly get application update status information from target cloud" do
356
+ VCR.use_cassette("user_logged/apps_update_info_action", :record => :new_episodes, :exclusive => true) do
357
+ update_info = @cf_client.update_app_info("newapp")
358
+ update_info.should have_key :state
359
+ update_info.should have_key :since
360
+ end
361
+ end
362
+
363
+ it "should properly get application bits from target cloud" do
364
+ VCR.use_cassette("user_logged/apps_download_action", :record => :new_episodes, :exclusive => true) do
365
+ appbits = @cf_client.download_app("newapp")
366
+ appbits.should_not be_empty
367
+ end
368
+ end
369
+
370
+ it "should properly get directory information for an application at target cloud" do
371
+ VCR.use_cassette("user_logged/apps_directory_action", :record => :new_episodes, :exclusive => true) do
372
+ app_files = @cf_client.app_files("newapp", "/app")
373
+ app_files.should include("app.js")
374
+ end
375
+ end
376
+
377
+ it "should properly get file information for an application at target cloud" do
378
+ VCR.use_cassette("user_logged/apps_file_action", :record => :new_episodes, :exclusive => true) do
379
+ app_file = @cf_client.app_files("newapp", "/app/app.js")
380
+ filebits = ""
381
+ filename = spec_fixture("app.js")
382
+ appfile = File.new(filename, "r")
383
+ while (line = appfile.gets)
384
+ filebits += line
385
+ end
386
+ appfile.close
387
+ app_file.should eql(filebits)
388
+ end
389
+ end
390
+
391
+ it "should raise an ServerError exception when retrieving files information for a file that does not exists at target cloud" do
392
+ expect {
393
+ app_files = @cf_client.app_files("newapp", "/app/nofile")
394
+ }.to raise_exception(CloudFoundry::Client::Exception::ServerError)
395
+ end
396
+
397
+ it "should properly get application stats information from target cloud" do
398
+ VCR.use_cassette("user_logged/apps_stats_action", :record => :new_episodes, :exclusive => true) do
399
+ app_stats = @cf_client.app_stats("newapp")
400
+ app_stats.should have_at_least(1).items
401
+ app_stats_info = app_stats.first
402
+ app_stats_info.should have_key :stats
403
+ end
404
+ end
405
+
406
+ it "should raise a BadParams exception when deleting an application with a blank name" do
407
+ expect {
408
+ deleted = @cf_client.delete_app("")
409
+ }.to raise_exception(CloudFoundry::Client::Exception::BadParams)
410
+ end
411
+
412
+ it "should raise a NotFound exception when deleting an application that does not exists at target cloud" do
413
+ expect {
414
+ deleted = @cf_client.delete_app("noapp")
415
+ }.to raise_exception(CloudFoundry::Client::Exception::NotFound)
416
+ end
417
+
418
+ it "should return true if an application is deleted at target cloud" do
419
+ deleted = @cf_client.delete_app("newapp")
420
+ deleted.should be_true
421
+ end
422
+ end
423
+ end