static 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,319 @@
1
+ require 'spec_helper'
2
+ require 'manifests-vmc-plugin'
3
+
4
+ describe VMCManifests do
5
+ let(:inputs_hash) { {} }
6
+ let(:given_hash) { {} }
7
+ let(:global_hash) { {} }
8
+ let(:inputs) { Mothership::Inputs.new(nil, nil, inputs_hash, given_hash, global_hash) }
9
+
10
+ let(:cmd) do
11
+ manifest = VMC::App::Push.new(nil, inputs)
12
+ manifest.extend VMCManifests
13
+ stub(manifest).client { client }
14
+ manifest
15
+ end
16
+
17
+ let(:target_base) { "some-cloud.com" }
18
+
19
+ let(:foo) { fake(:app, :name => "foo") }
20
+ let(:bar) { fake(:app, :name => "bar") }
21
+ let(:baz) { fake(:app, :name => "baz") }
22
+ let(:xxx) { fake(:app, :name => "xxx") }
23
+ let(:yyy) { fake(:app, :name => "yyy") }
24
+
25
+ let(:client) do
26
+ fake_client :apps => [foo, bar, baz, xxx, yyy]
27
+ end
28
+
29
+ let(:manifest_file) { "/abc/manifest.yml" }
30
+
31
+ before do
32
+ stub(cmd).target_base { target_base }
33
+ stub(cmd).v2? { true }
34
+
35
+ stub(cmd).manifest { manifest }
36
+ stub(cmd).manifest_file { manifest_file }
37
+ end
38
+
39
+ describe '#find_apps' do
40
+ subject { cmd.find_apps(nil) }
41
+
42
+ context 'when there is no manifest file' do
43
+ before { stub(cmd).manifest { nil } }
44
+ it { should eq [] }
45
+ end
46
+ end
47
+
48
+ describe '#create_manifest_for' do
49
+ let(:app) {
50
+ fake :app,
51
+ :framework => fake(:framework),
52
+ :runtime => fake(:runtime),
53
+ :memory => 2048,
54
+ :total_instances => 2,
55
+ :command => "ruby main.rb",
56
+ :routes => [
57
+ fake(:route,
58
+ :host => "some-app-name",
59
+ :domain => fake(:domain, :name => target_base))
60
+ ],
61
+ :service_bindings => [
62
+ fake(
63
+ :service_binding,
64
+ :service_instance =>
65
+ fake(
66
+ :service_instance,
67
+ :name => "service-1",
68
+ :service_plan =>
69
+ fake(
70
+ :service_plan,
71
+ :name => "P200",
72
+ :service => fake(:service))))
73
+ ]
74
+ }
75
+
76
+ subject { cmd.create_manifest_for(app, "some-path") }
77
+
78
+ its(["name"]) { should eq app.name }
79
+ its(["framework"]) { should eq app.framework.name }
80
+ its(["runtime"]) { should eq app.runtime.name }
81
+ its(["memory"]) { should eq "2G" }
82
+ its(["instances"]) { should eq 2 }
83
+ its(["path"]) { should eq "some-path" }
84
+ its(["url"]) { should eq "some-app-name.${target-base}" }
85
+ its(["command"]) { should eq "ruby main.rb" }
86
+
87
+ it "contains the service information" do
88
+ expect(subject["services"]).to be_a Hash
89
+
90
+ services = subject["services"]
91
+ app.service_bindings.each do |b|
92
+ service = b.service_instance
93
+
94
+ expect(services).to include service.name
95
+
96
+ info = services[service.name]
97
+
98
+ plan = service.service_plan
99
+ offering = plan.service
100
+
101
+ { "plan" => plan.name,
102
+ "label" => offering.label,
103
+ "provider" => offering.provider,
104
+ "version" => offering.version
105
+ }.each do |attr, val|
106
+ expect(info).to include attr
107
+ expect(info[attr]).to eq val
108
+ end
109
+ end
110
+ end
111
+
112
+ context 'when there is no url' do
113
+ let(:app) {
114
+ fake :app,
115
+ :framework => fake(:framework),
116
+ :runtime => fake(:runtime),
117
+ :memory => 2048,
118
+ :total_instances => 2
119
+ }
120
+
121
+ its(["url"]) { should eq "none" }
122
+ end
123
+
124
+ context 'when there is no command' do
125
+ let(:app) {
126
+ fake :app,
127
+ :framework => fake(:framework),
128
+ :runtime => fake(:runtime),
129
+ :memory => 2048,
130
+ :total_instances => 2
131
+ }
132
+
133
+ it { should_not include "command" }
134
+ end
135
+
136
+ context 'when there are no service bindings' do
137
+ let(:app) {
138
+ fake :app,
139
+ :framework => fake(:framework),
140
+ :runtime => fake(:runtime),
141
+ :memory => 2048,
142
+ :total_instances => 2
143
+ }
144
+
145
+ it { should_not include "services" }
146
+ end
147
+ end
148
+
149
+ describe "#setup_services" do
150
+ let(:service_bindings) { [] }
151
+ let(:app) { fake :app, :service_bindings => service_bindings }
152
+
153
+ before do
154
+ dont_allow_ask(anything, anything)
155
+ end
156
+
157
+ context "when services are defined in the manifest" do
158
+ let(:info) {
159
+ { :services => { "service-1" => { :label => "mysql", :plan => "100" } } }
160
+ }
161
+
162
+ let(:service_1) { fake(:service_instance, :name => "service-1") }
163
+
164
+ let(:plan_100) { fake :service_plan, :name => "100" }
165
+
166
+ let(:mysql) {
167
+ fake(
168
+ :service,
169
+ :label => "mysql",
170
+ :provider => "core",
171
+ :service_plans => [plan_100])
172
+ }
173
+
174
+ let(:service_instances) { [] }
175
+
176
+ let(:client) {
177
+ fake_client :services => [mysql], :service_instances => service_instances
178
+ }
179
+
180
+ context "and the services exist" do
181
+ let(:service_instances) { [service_1] }
182
+
183
+ context "and are already bound" do
184
+ let(:service_bindings) { [fake(:service_binding, :service_instance => service_1)] }
185
+
186
+ it "does neither create nor bind the service again" do
187
+ dont_allow(cmd).invoke :create_service, anything
188
+ dont_allow(cmd).invoke :bind_service, anything
189
+ cmd.send(:setup_services, app, info)
190
+ end
191
+ end
192
+
193
+ context "but are not bound" do
194
+ it "does not create the services" do
195
+ dont_allow(cmd).invoke :create_service, anything
196
+ stub(cmd).invoke :bind_service, anything
197
+ cmd.send(:setup_services, app, info)
198
+ end
199
+
200
+ it "binds the service" do
201
+ mock(cmd).invoke :bind_service, :app => app, :service => service_1
202
+ cmd.send(:setup_services, app, info)
203
+ end
204
+ end
205
+ end
206
+
207
+ context "and the services do not exist" do
208
+ it "creates the services" do
209
+ mock(cmd).invoke :create_service, :app => app,
210
+ :name => service_1.name, :offering => mysql, :plan => plan_100
211
+ dont_allow(cmd).invoke :bind_service, anything
212
+ cmd.send(:setup_services, app, info)
213
+ end
214
+ end
215
+ end
216
+
217
+ context "when there are no services defined" do
218
+ let(:info) { {} }
219
+
220
+ it "does not ask anything" do
221
+ cmd.send(:setup_services, app, info)
222
+ end
223
+ end
224
+ end
225
+
226
+ describe "#apps_in_manifest" do
227
+ let(:foo_hash) { { :name => "foo", :path => "/abc/foo" } }
228
+ let(:bar_hash) { { :name => "bar", :path => "/abc/bar" } }
229
+ let(:baz_hash) { { :name => "baz", :path => "/abc/baz" } }
230
+
231
+ let(:manifest) { { :applications => [foo_hash, bar_hash, baz_hash] } }
232
+
233
+ subject { cmd.apps_in_manifest(inputs) }
234
+
235
+ context "when no apps are passed" do
236
+ let(:given_hash) { {} }
237
+
238
+ its(:first) { should eq [] }
239
+ its(:last) { should eq [] }
240
+ end
241
+
242
+ context "when app names are passed" do
243
+ context "and all of them are in the manifest" do
244
+ let(:given_hash) { { :apps => ["foo", "bar"] } }
245
+
246
+ its(:first) { should eq [foo_hash, bar_hash] }
247
+ its(:last) { should eq [] }
248
+ end
249
+
250
+ context "and one of them is in the manifest" do
251
+ let(:given_hash) { { :apps => ["foo", "xxx"] } }
252
+
253
+ its(:first) { should eq [foo_hash] }
254
+ its(:last) { should eq ["xxx"] }
255
+ end
256
+
257
+ context "and none of them are in the manifest" do
258
+ let(:given_hash) { { :apps => ["xxx", "yyy"] } }
259
+
260
+ its(:first) { should eq [] }
261
+ its(:last) { should eq ["xxx", "yyy"] }
262
+ end
263
+ end
264
+
265
+ context "when apps are passed as paths" do
266
+ context "and the paths are in the manifest" do
267
+ let(:given_hash) { { :apps => ["/abc/foo"] } }
268
+
269
+ its(:first) { should eq [foo_hash] }
270
+ its(:last) { should eq [] }
271
+ end
272
+
273
+ context "and any path is not in the manifest" do
274
+ let(:given_hash) { { :apps => ["/abc/xxx"] } }
275
+
276
+ it "fails with a manifest-specific method (i.e. path not in manifest)" do
277
+ expect { subject }.to raise_error(VMC::UserError, /Path .+ is not present in manifest/)
278
+ end
279
+ end
280
+ end
281
+ end
282
+
283
+ describe "#all_apps" do
284
+ let(:applications) do
285
+ [
286
+ {:name => "foo", :path => "/abc"},
287
+ {:name => "bar", :path => "/abc"},
288
+ {:name => "baz", :path => "/abc/baz"}
289
+ ]
290
+ end
291
+
292
+ let(:manifest) do
293
+ { :applications => applications }
294
+ end
295
+
296
+ subject { cmd.all_apps }
297
+
298
+ it "returns all of the apps described in the manifest, as hashes" do
299
+ expect(subject).to eq applications
300
+ end
301
+ end
302
+
303
+ describe "#current_apps" do
304
+ let(:manifest) do
305
+ {:applications => [
306
+ {:name => "foo", :path => "/abc"},
307
+ {:name => "bar", :path => "/abc"},
308
+ {:name => "baz", :path => "/abc/baz"}
309
+ ]}
310
+ end
311
+
312
+ subject { cmd.current_apps }
313
+
314
+ it "returns the applications with the cwd as their path" do
315
+ stub(Dir).pwd { "/abc" }
316
+ expect(subject).to eq [{ :name => "foo", :path => "/abc"}, { :name => "bar", :path => "/abc" }]
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,16 @@
1
+ SPEC_ROOT = File.dirname(__FILE__).freeze
2
+
3
+ require "rspec"
4
+ require "vmc"
5
+ require "cfoundry"
6
+ require "webmock"
7
+ require "cfoundry/test_support"
8
+ require "vmc/test_support"
9
+
10
+ WebMock.disable_net_connect!
11
+
12
+ RSpec.configure do |c|
13
+ c.include Fake::FakeMethods
14
+ c.include VMC::TestSupport::InteractHelper
15
+ c.mock_with :rr
16
+ end
@@ -0,0 +1,50 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.6)
5
+ async_sinatra (0.5.0)
6
+ rack (>= 1.2.1)
7
+ sinatra (>= 1.0)
8
+ backports (3.3.0)
9
+ caldecott (0.0.3)
10
+ addressable (= 2.2.6)
11
+ async_sinatra (= 0.5.0)
12
+ em-http-request (= 0.3.0)
13
+ em-websocket (= 0.3.1)
14
+ json (= 1.6.1)
15
+ uuidtools (= 2.1.2)
16
+ daemons (1.1.9)
17
+ em-http-request (0.3.0)
18
+ addressable (>= 2.0.0)
19
+ escape_utils
20
+ eventmachine (>= 0.12.9)
21
+ em-websocket (0.3.1)
22
+ addressable (>= 2.1.1)
23
+ eventmachine (>= 0.12.9)
24
+ escape_utils (0.3.2)
25
+ eventmachine (1.0.3)
26
+ json (1.6.1)
27
+ rack (1.2.8)
28
+ sinatra (1.2.9)
29
+ backports
30
+ rack (~> 1.1, < 1.5)
31
+ tilt (>= 1.2.2, < 2.0)
32
+ thin (1.5.1)
33
+ daemons (>= 1.0.9)
34
+ eventmachine (>= 0.12.6)
35
+ rack (>= 1.0.0)
36
+ tilt (1.4.1)
37
+ uuidtools (2.1.2)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ async_sinatra
44
+ bundler
45
+ caldecott (= 0.0.3)
46
+ em-websocket
47
+ json
48
+ rack (~> 1.2.0)
49
+ thin
50
+ uuidtools
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Static Development
@@ -10,7 +10,7 @@ bindir:
10
10
  - bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-04-08 00:00:00 Z
13
+ date: 2013-05-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json_pure
@@ -135,56 +135,46 @@ dependencies:
135
135
  version: 1.3.8
136
136
  type: :runtime
137
137
  version_requirements: *id012
138
- - !ruby/object:Gem::Dependency
139
- name: manifests-vmc-plugin
140
- prerelease: false
141
- requirement: &id013 !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ~>
144
- - !ruby/object:Gem::Version
145
- version: 0.6.2
146
- type: :runtime
147
- version_requirements: *id013
148
138
  - !ruby/object:Gem::Dependency
149
139
  name: rake
150
140
  prerelease: false
151
- requirement: &id014 !ruby/object:Gem::Requirement
141
+ requirement: &id013 !ruby/object:Gem::Requirement
152
142
  requirements:
153
143
  - - ~>
154
144
  - !ruby/object:Gem::Version
155
145
  version: "0.9"
156
146
  type: :development
157
- version_requirements: *id014
147
+ version_requirements: *id013
158
148
  - !ruby/object:Gem::Dependency
159
149
  name: rspec
160
150
  prerelease: false
161
- requirement: &id015 !ruby/object:Gem::Requirement
151
+ requirement: &id014 !ruby/object:Gem::Requirement
162
152
  requirements:
163
153
  - - ~>
164
154
  - !ruby/object:Gem::Version
165
155
  version: "2.11"
166
156
  type: :development
167
- version_requirements: *id015
157
+ version_requirements: *id014
168
158
  - !ruby/object:Gem::Dependency
169
159
  name: webmock
170
160
  prerelease: false
171
- requirement: &id016 !ruby/object:Gem::Requirement
161
+ requirement: &id015 !ruby/object:Gem::Requirement
172
162
  requirements:
173
163
  - - ~>
174
164
  - !ruby/object:Gem::Version
175
165
  version: "1.9"
176
166
  type: :development
177
- version_requirements: *id016
167
+ version_requirements: *id015
178
168
  - !ruby/object:Gem::Dependency
179
169
  name: rr
180
170
  prerelease: false
181
- requirement: &id017 !ruby/object:Gem::Requirement
171
+ requirement: &id016 !ruby/object:Gem::Requirement
182
172
  requirements:
183
173
  - - ~>
184
174
  - !ruby/object:Gem::Version
185
175
  version: "1.0"
186
176
  type: :development
187
- version_requirements: *id017
177
+ version_requirements: *id016
188
178
  description: " Static.com Cloud Command Line Client "
189
179
  email:
190
180
  - support@static.com
@@ -351,8 +341,22 @@ files:
351
341
  - vendor/cfoundry-0.5.2/vendor/errors/README.md
352
342
  - vendor/cfoundry-0.5.2/vendor/errors/v1.yml
353
343
  - vendor/cfoundry-0.5.2/vendor/errors/v2.yml
344
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/errors.rb
345
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/loader/builder.rb
346
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/loader/normalizer.rb
347
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/loader/resolver.rb
348
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/loader.rb
349
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/plugin.rb
350
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/version.rb
351
+ - vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin.rb
352
+ - vendor/manifests-vmc-plugin-0.6.2/Rakefile
353
+ - vendor/manifests-vmc-plugin-0.6.2/spec/manifests-vmc-plugin/loader/normalizer_spec.rb
354
+ - vendor/manifests-vmc-plugin-0.6.2/spec/manifests-vmc-plugin/loader/plugin_spec.rb
355
+ - vendor/manifests-vmc-plugin-0.6.2/spec/manifests-vmc-plugin_spec.rb
356
+ - vendor/manifests-vmc-plugin-0.6.2/spec/spec_helper.rb
354
357
  - vendor/tunnel-vmc-plugin-0.2.2/config/clients.yml
355
358
  - vendor/tunnel-vmc-plugin-0.2.2/helper-app/Gemfile
359
+ - vendor/tunnel-vmc-plugin-0.2.2/helper-app/Gemfile.lock
356
360
  - vendor/tunnel-vmc-plugin-0.2.2/helper-app/server.rb
357
361
  - vendor/tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/plugin.rb
358
362
  - vendor/tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/tunnel.rb
@@ -496,8 +500,8 @@ files:
496
500
  - vendor/vmc-0.5.0/spec/vmc/detect_spec.rb
497
501
  - bin/static
498
502
  homepage: http://www.static.com/
499
- licenses: []
500
-
503
+ licenses:
504
+ - Apache v2.0
501
505
  metadata: {}
502
506
 
503
507
  post_install_message:
@@ -508,13 +512,13 @@ require_paths:
508
512
  - vendor
509
513
  required_ruby_version: !ruby/object:Gem::Requirement
510
514
  requirements:
511
- - &id018
515
+ - &id017
512
516
  - ">="
513
517
  - !ruby/object:Gem::Version
514
518
  version: "0"
515
519
  required_rubygems_version: !ruby/object:Gem::Requirement
516
520
  requirements:
517
- - *id018
521
+ - *id017
518
522
  requirements: []
519
523
 
520
524
  rubyforge_project: static