vmc 0.5.0.beta.6 → 0.5.0.beta.7

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.
@@ -6,7 +6,7 @@ describe VMC::App::Push do
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
8
  let(:path) { "somepath" }
9
- let(:client) { FactoryGirl.build(:client) }
9
+ let(:client) { fake_client }
10
10
  let(:push) { VMC::App::Push.new(Mothership.commands[:push]) }
11
11
 
12
12
  before do
@@ -36,7 +36,7 @@ describe VMC::App::Push do
36
36
  end
37
37
 
38
38
  describe '#sync_app' do
39
- let(:app) { FactoryGirl.build(:app) }
39
+ let(:app) { fake(:app) }
40
40
 
41
41
  before do
42
42
  stub(app).upload
@@ -87,7 +87,7 @@ describe VMC::App::Push do
87
87
  context 'when memory is given' do
88
88
  let(:old) { 1024 }
89
89
  let(:new) { "2G" }
90
- let(:app) { FactoryGirl.build(:app, :memory => old) }
90
+ let(:app) { fake(:app, :memory => old) }
91
91
  let(:inputs) { { :memory => new } }
92
92
 
93
93
  it 'updates the app memory, converting to megabytes' do
@@ -109,7 +109,7 @@ describe VMC::App::Push do
109
109
  context 'when instances is given' do
110
110
  let(:old) { 1 }
111
111
  let(:new) { 2 }
112
- let(:app) { FactoryGirl.build(:app, :total_instances => old) }
112
+ let(:app) { fake(:app, :total_instances => old) }
113
113
  let(:inputs) { { :instances => new } }
114
114
 
115
115
  it 'updates the app instances' do
@@ -129,9 +129,9 @@ describe VMC::App::Push do
129
129
  end
130
130
 
131
131
  context 'when framework is given' do
132
- let(:old) { FactoryGirl.build(:framework, :name => "Old Framework") }
133
- let(:new) { FactoryGirl.build(:framework, :name => "New Framework") }
134
- let(:app) { FactoryGirl.build(:app, :framework => old) }
132
+ let(:old) { fake(:framework, :name => "Old Framework") }
133
+ let(:new) { fake(:framework, :name => "New Framework") }
134
+ let(:app) { fake(:app, :framework => old) }
135
135
  let(:inputs) { { :framework => new } }
136
136
 
137
137
  it 'updates the app framework' do
@@ -151,9 +151,9 @@ describe VMC::App::Push do
151
151
  end
152
152
 
153
153
  context 'when runtime is given' do
154
- let(:old) { FactoryGirl.build(:runtime, :name => "Old Runtime") }
155
- let(:new) { FactoryGirl.build(:runtime, :name => "New Runtime") }
156
- let(:app) { FactoryGirl.build(:app, :runtime => old) }
154
+ let(:old) { fake(:runtime, :name => "Old Runtime") }
155
+ let(:new) { fake(:runtime, :name => "New Runtime") }
156
+ let(:app) { fake(:app, :runtime => old) }
157
157
  let(:inputs) { { :runtime => new } }
158
158
 
159
159
  it 'updates the app runtime' do
@@ -175,7 +175,7 @@ describe VMC::App::Push do
175
175
  context 'when command is given' do
176
176
  let(:old) { "./start" }
177
177
  let(:new) { "./start foo " }
178
- let(:app) { FactoryGirl.build(:app, :command => old) }
178
+ let(:app) { fake(:app, :command => old) }
179
179
  let(:inputs) { { :command => new } }
180
180
 
181
181
  it 'updates the app command' do
@@ -222,7 +222,7 @@ describe VMC::App::Push do
222
222
 
223
223
  %w{d100 D100 D200 fizzbuzz}.each do |plan|
224
224
  context "when the given plan is #{plan}" do
225
- let(:app) { FactoryGirl.build(:app, :production => true) }
225
+ let(:app) { fake(:app, :production => true) }
226
226
 
227
227
  let(:inputs) { { :plan => plan } }
228
228
 
@@ -247,7 +247,7 @@ describe VMC::App::Push do
247
247
 
248
248
 
249
249
  context 'when the app is already started' do
250
- let(:app) { FactoryGirl.build(:app, :state => "STARTED") }
250
+ let(:app) { fake(:app, :state => "STARTED") }
251
251
 
252
252
  it 'invokes the restart command' do
253
253
  stub(push).line
@@ -269,7 +269,7 @@ describe VMC::App::Push do
269
269
  end
270
270
 
271
271
  context 'when the app is not already started' do
272
- let(:app) { FactoryGirl.build(:app, :state => "STOPPED") }
272
+ let(:app) { fake(:app, :state => "STOPPED") }
273
273
 
274
274
  it 'does not invoke the restart command' do
275
275
  stub(push).line
@@ -282,9 +282,9 @@ describe VMC::App::Push do
282
282
  end
283
283
 
284
284
  describe '#setup_new_app (integration spec!!)' do
285
- let(:app) { FactoryGirl.build(:app, :guid => nil) }
286
- let(:framework) { FactoryGirl.build(:framework) }
287
- let(:runtime) { FactoryGirl.build(:runtime) }
285
+ let(:app) { fake(:app, :guid => nil) }
286
+ let(:framework) { fake(:framework) }
287
+ let(:runtime) { fake(:runtime) }
288
288
  let(:url) { "https://www.foobar.com" }
289
289
  let(:inputs) do
290
290
  { :name => "some-app",
@@ -5,7 +5,7 @@ describe VMC::App::Rename do
5
5
  let(:global) { { :color => false, :quiet => true } }
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
- let(:client) { FactoryGirl.build(:client) }
8
+ let(:client) { fake_client }
9
9
  let(:app) {}
10
10
  let(:new_name) { "some-new-name" }
11
11
 
@@ -52,8 +52,8 @@ describe VMC::App::Rename do
52
52
  end
53
53
 
54
54
  context 'when there are apps' do
55
- let(:client) { FactoryGirl.build(:client, :apps => apps) }
56
- let(:apps) { FactoryGirl.build_list(:app, 2) }
55
+ let(:client) { fake_client(:apps => apps) }
56
+ let(:apps) { fake_list(:app, 2) }
57
57
  let(:renamed_app) { apps.first }
58
58
 
59
59
  context 'when the defaults are used' do
@@ -95,7 +95,7 @@ describe VMC::App::Rename do
95
95
 
96
96
  context 'and the name already exists' do
97
97
  it 'fails' do
98
- mock(renamed_app).update! { raise CFoundry::AppNameTaken }
98
+ mock(renamed_app).update! { raise CFoundry::AppNameTaken.new(nil, nil, "Bad Name", 404) }
99
99
  expect { subject }.to raise_error(CFoundry::AppNameTaken)
100
100
  end
101
101
  end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+ describe VMC::App::Stats do
5
+ let(:global) { { :color => false } }
6
+ let(:inputs) { {:app => apps[0]} }
7
+ let(:given) { {} }
8
+ let(:output) { StringIO.new }
9
+ let(:client) { fake_client(:apps => apps) }
10
+ let(:apps) { [fake(:app, :name => "basic_app")] }
11
+
12
+ before do
13
+ any_instance_of(VMC::CLI) do |cli|
14
+ stub(cli).client { client }
15
+ stub(cli).precondition { nil }
16
+ end
17
+ stub(client).base.stub!.stats do
18
+ {"0" => {
19
+ :state => "RUNNING",
20
+ :stats => {
21
+ :name => "basic_app",
22
+ :uris => ["basic_app.p01.rbconsvcs.com"],
23
+ :host => "172.20.183.93",
24
+ :port => 61006,
25
+ :uptime => 3250,
26
+ :mem_quota => 301989888,
27
+ :disk_quota => 268435456,
28
+ :fds_quota => 256,
29
+ :usage => {:time => "2013-01-04 19:53:39 +0000", :cpu => 0.0019777013519415455, :mem => 31395840, :disk => 15638528}
30
+ }
31
+ }}
32
+ end
33
+ end
34
+
35
+ subject do
36
+ with_output_to output do
37
+ Mothership.new.invoke(:stats, inputs, given, global)
38
+ end
39
+ end
40
+
41
+ describe 'metadata' do
42
+ let(:command) { Mothership.commands[:stats] }
43
+
44
+ describe 'command' do
45
+ subject { command }
46
+ its(:description) { should eq "Display application instance status" }
47
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
48
+ end
49
+
50
+ include_examples 'inputs must have descriptions'
51
+
52
+ describe 'arguments' do
53
+ subject { command.arguments }
54
+ it 'has no arguments' do
55
+ should eq([:name=>:app, :type=>:normal, :value=>nil])
56
+ end
57
+ end
58
+ end
59
+
60
+ it 'prints out the stats' do
61
+ subject
62
+
63
+ output.rewind
64
+ expect(output.readlines.last).to match /.*0\s+0\.0% of\s+cores\s+29\.9M of 288M\s+14\.9M of 256M.*/
65
+ end
66
+ end
@@ -6,11 +6,12 @@ describe VMC::Organization::Orgs do
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
8
  let(:output) { StringIO.new }
9
- let!(:org_1) { FactoryGirl.build(:organization, :name => "bb_second", :spaces => FactoryGirl.build_list(:space, 2), :domains => [FactoryGirl.build(:domain)]) }
10
- let!(:org_2) { FactoryGirl.build(:organization, :name => "aa_first", :spaces => [FactoryGirl.build(:space)], :domains => FactoryGirl.build_list(:domain, 3)) }
11
- let!(:org_3) { FactoryGirl.build(:organization, :name => "cc_last", :spaces => FactoryGirl.build_list(:space, 2), :domains => FactoryGirl.build_list(:domain, 2)) }
9
+
10
+ let(:client) { fake_client(:organizations => organizations) }
11
+ let!(:org_1) { fake(:organization, :name => "bb_second", :spaces => fake_list(:space, 2), :domains => [fake(:domain)]) }
12
+ let!(:org_2) { fake(:organization, :name => "aa_first", :spaces => [fake(:space)], :domains => fake_list(:domain, 3)) }
13
+ let!(:org_3) { fake(:organization, :name => "cc_last", :spaces => fake_list(:space, 2), :domains => fake_list(:domain, 2)) }
12
14
  let(:organizations) { [org_1, org_2, org_3]}
13
- let(:client) { FactoryGirl.build(:client, :organizations => organizations) }
14
15
 
15
16
  before do
16
17
  any_instance_of(VMC::CLI) do |cli|
@@ -5,8 +5,8 @@ describe VMC::Organization::Rename do
5
5
  let(:global) { { :color => false, :quiet => true } }
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
- let(:organizations) { FactoryGirl.build_list(:organization, 3) }
9
- let(:client) { FactoryGirl.build(:client, :organizations => organizations) }
8
+ let(:organizations) { fake_list(:organization, 3) }
9
+ let(:client) { fake_client(:organizations => organizations) }
10
10
  let(:new_name) { "some-new-name" }
11
11
 
12
12
  before do
@@ -104,7 +104,7 @@ describe VMC::Organization::Rename do
104
104
 
105
105
  context 'and the name already exists' do
106
106
  it 'fails' do
107
- mock(renamed_organization).update! { raise CFoundry::OrganizationNameTaken }
107
+ mock(renamed_organization).update! { raise CFoundry::OrganizationNameTaken.new(nil, nil, "Bad error", 200) }
108
108
  expect { subject }.to raise_error(CFoundry::OrganizationNameTaken)
109
109
  end
110
110
  end
@@ -5,7 +5,7 @@ describe VMC::Route::Delete do
5
5
  let(:global) { { :color => false, :quiet => true } }
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
- let(:client) { FactoryGirl.build(:client) }
8
+ let(:client) { fake_client }
9
9
 
10
10
  before do
11
11
  any_instance_of(VMC::CLI) do |cli|
@@ -56,8 +56,8 @@ describe VMC::Route::Delete do
56
56
  end
57
57
 
58
58
  context "when there are routes" do
59
- let(:client) { FactoryGirl.build(:client, :routes => routes) }
60
- let(:routes) { FactoryGirl.build_list(:route, 2) }
59
+ let(:client) { fake_client(:routes => routes) }
60
+ let(:routes) { fake_list(:route, 2) }
61
61
  let(:deleted_route) { routes.first }
62
62
 
63
63
  context 'when the defaults are used' do
@@ -5,7 +5,7 @@ describe VMC::Service::Rename do
5
5
  let(:global) { { :color => false, :quiet => true } }
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
- let(:client) { FactoryGirl.build(:client) }
8
+ let(:client) { fake_client }
9
9
  let(:service) {}
10
10
  let(:new_name) { "some-new-name" }
11
11
 
@@ -52,8 +52,8 @@ describe VMC::Service::Rename do
52
52
  end
53
53
 
54
54
  context 'when there are services' do
55
- let(:client) { FactoryGirl.build(:client, :service_instances => services) }
56
- let(:services) { FactoryGirl.build_list(:service_instance, 2) }
55
+ let(:client) { fake_client(:service_instances => services) }
56
+ let(:services) { fake_list(:service_instance, 2) }
57
57
  let(:renamed_service) { services.first }
58
58
 
59
59
  context 'when the defaults are used' do
@@ -95,7 +95,7 @@ describe VMC::Service::Rename do
95
95
 
96
96
  context 'and the name already exists' do
97
97
  it 'fails' do
98
- mock(renamed_service).update! { raise CFoundry::ServiceInstanceNameTaken }
98
+ mock(renamed_service).update! { raise CFoundry::ServiceInstanceNameTaken.new nil, nil, "Taken", 200 }
99
99
  expect { subject }.to raise_error(CFoundry::ServiceInstanceNameTaken)
100
100
  end
101
101
  end
@@ -5,9 +5,9 @@ describe VMC::Space::Rename do
5
5
  let(:global) { { :color => false, :quiet => true } }
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
- let(:spaces) { FactoryGirl.build_list(:space, 3) }
9
- let(:organization) { FactoryGirl.build(:organization, :spaces => spaces) }
10
- let(:client) { FactoryGirl.build(:client, :current_organization => organization, :spaces => spaces) }
8
+ let(:spaces) { fake_list(:space, 3) }
9
+ let(:organization) { fake(:organization, :spaces => spaces) }
10
+ let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
11
11
  let(:new_name) { "some-new-name" }
12
12
 
13
13
  before do
@@ -96,7 +96,7 @@ describe VMC::Space::Rename do
96
96
 
97
97
  context 'and the name already exists' do
98
98
  it 'fails' do
99
- mock(renamed_space).update! { raise CFoundry::SpaceNameTaken }
99
+ mock(renamed_space).update! { raise CFoundry::SpaceNameTaken.new nil, nil, "Taken", 404 }
100
100
  expect { subject }.to raise_error(CFoundry::SpaceNameTaken)
101
101
  end
102
102
  end
@@ -6,12 +6,12 @@ describe VMC::Space::Spaces do
6
6
  let(:inputs) { {} }
7
7
  let(:given) { {} }
8
8
  let(:output) { StringIO.new }
9
- let!(:space_1) { FactoryGirl.build(:space, :name => "bb_second", :apps => FactoryGirl.build_list(:app, 2), :service_instances => [FactoryGirl.build(:service_instance)]) }
10
- let!(:space_2) { FactoryGirl.build(:space, :name => "aa_first", :apps => [FactoryGirl.build(:app)], :service_instances => FactoryGirl.build_list(:service_instance, 3), :domains => [FactoryGirl.build(:domain)]) }
11
- let!(:space_3) { FactoryGirl.build(:space, :name => "cc_last", :apps => FactoryGirl.build_list(:app, 2), :service_instances => FactoryGirl.build_list(:service_instance, 2), :domains => FactoryGirl.build_list(:domain, 2)) }
9
+ let!(:space_1) { fake(:space, :name => "bb_second", :apps => fake_list(:app, 2), :service_instances => [fake(:service_instance)]) }
10
+ let!(:space_2) { fake(:space, :name => "aa_first", :apps => [fake(:app)], :service_instances => fake_list(:service_instance, 3), :domains => [fake(:domain)]) }
11
+ let!(:space_3) { fake(:space, :name => "cc_last", :apps => fake_list(:app, 2), :service_instances => fake_list(:service_instance, 2), :domains => fake_list(:domain, 2)) }
12
12
  let(:spaces) { [space_1, space_2, space_3]}
13
- let(:organization) { FactoryGirl.build(:organization, :spaces => spaces) }
14
- let(:client) { FactoryGirl.build(:client, :spaces => spaces, :current_organization => organization) }
13
+ let(:organization) { fake(:organization, :spaces => spaces) }
14
+ let(:client) { fake_client(:spaces => spaces, :current_organization => organization) }
15
15
 
16
16
  before do
17
17
  any_instance_of(VMC::CLI) do |cli|
@@ -1,6 +1,36 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe VMC::Start::Info do
4
+ let(:global) { { :color => false } }
5
+ let(:inputs) { {} }
6
+ let(:given) { {} }
7
+ let(:output) { StringIO.new }
8
+
9
+ let(:client) {
10
+ fake_client :frameworks => fake_list(:framework, 3),
11
+ :runtimes => fake_list(:runtime, 3),
12
+ :services => fake_list(:service, 3)
13
+ }
14
+
15
+ let(:target_info) {
16
+ { :description => "Some description",
17
+ :version => 2,
18
+ :support => "http://example.com"
19
+ }
20
+ }
21
+
22
+ before do
23
+ any_instance_of(VMC::CLI) do |cli|
24
+ stub(cli).client { client }
25
+ end
26
+ end
27
+
28
+ subject do
29
+ with_output_to output do
30
+ Mothership.new.invoke(:info, inputs, given, global)
31
+ end
32
+ end
33
+
4
34
  describe 'metadata' do
5
35
  let(:command) { Mothership.commands[:info] }
6
36
 
@@ -26,4 +56,100 @@ describe VMC::Start::Info do
26
56
  it { should be_empty }
27
57
  end
28
58
  end
29
- end
59
+
60
+ context 'when given no flags' do
61
+ it "displays target information" do
62
+ mock(client).info { target_info }
63
+
64
+ subject
65
+
66
+ output.rewind
67
+ expect(output.readline).to eq "Some description\n"
68
+ expect(output.readline).to eq "\n"
69
+ expect(output.readline).to eq "target: #{client.target}\n"
70
+ expect(output.readline).to eq " version: 2\n"
71
+ expect(output.readline).to eq " support: http://example.com\n"
72
+ end
73
+ end
74
+
75
+ context 'when given --frameworks' do
76
+ let(:inputs) { { :frameworks => true } }
77
+
78
+ it 'does not grab /info' do
79
+ dont_allow(client).info
80
+ subject
81
+ end
82
+
83
+ it 'lists frameworks on the target' do
84
+ subject
85
+
86
+ output.rewind
87
+ expect(output.readline).to match /Getting frameworks.*OK/
88
+ expect(output.readline).to eq "\n"
89
+ expect(output.readline).to match /framework\s+description/
90
+
91
+ client.frameworks.sort_by(&:name).each do |f|
92
+ expect(output.readline).to match /#{f.name}\s+#{f.description}/
93
+ end
94
+ end
95
+ end
96
+
97
+ context 'when given --runtimes' do
98
+ let(:inputs) { { :runtimes => true } }
99
+
100
+ it 'does not grab /info' do
101
+ dont_allow(client).info
102
+ subject
103
+ end
104
+
105
+ it 'lists runtimes on the target' do
106
+ subject
107
+
108
+ output.rewind
109
+ expect(output.readline).to match /Getting runtimes.*OK/
110
+ expect(output.readline).to eq "\n"
111
+ expect(output.readline).to match /runtime\s+description/
112
+
113
+ client.runtimes.sort_by(&:name).each do |r|
114
+ expect(output.readline).to match /#{r.name}\s+#{r.description}/
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'when given --services' do
120
+ let(:inputs) { { :services => true } }
121
+
122
+ it 'does not grab /info' do
123
+ dont_allow(client).info
124
+ subject
125
+ end
126
+
127
+ it 'lists services on the target' do
128
+ subject
129
+
130
+ output.rewind
131
+ expect(output.readline).to match /Getting services.*OK/
132
+ expect(output.readline).to eq "\n"
133
+ expect(output.readline).to match /service\s+version\s+provider\s+plans\s+description/
134
+
135
+ client.services.sort_by(&:label).each do |s|
136
+ expect(output.readline).to match /#{s.label}\s+#{s.version}\s+#{s.provider}.+#{s.description}/
137
+ end
138
+ end
139
+ end
140
+
141
+ context 'when given --all' do
142
+ let(:inputs) { { :all => true } }
143
+
144
+ it 'combines --frameworks --runtimes and --services' do
145
+ mock(client).info { target_info }
146
+
147
+ subject
148
+
149
+ output.rewind
150
+ expect(output.readline).to match /Getting runtimes.*OK/
151
+ expect(output.readline).to match /Getting frameworks.*OK/
152
+ expect(output.readline).to match /Getting services.*OK/
153
+ end
154
+ end
155
+ end