rhc 1.2.7 → 1.3.8
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.
- data/bin/rhc +6 -8
- data/bin/rhc-chk +23 -10
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -2
- data/features/lib/rhc_helper/api.rb +7 -0
- data/features/lib/rhc_helper/app.rb +8 -10
- data/features/lib/rhc_helper/domain.rb +2 -1
- data/features/lib/rhc_helper/runnable.rb +2 -24
- data/features/sshkey.feature +3 -3
- data/features/step_definitions/cartridge_steps.rb +6 -6
- data/features/step_definitions/client_steps.rb +0 -1
- data/features/step_definitions/sshkey_steps.rb +2 -2
- data/features/support/before_hooks.rb +0 -1
- data/features/support/env.rb +5 -3
- data/lib/rhc-common.rb +1 -1
- data/lib/rhc.rb +9 -8
- data/lib/rhc/auth.rb +3 -0
- data/lib/rhc/auth/basic.rb +54 -0
- data/lib/rhc/cartridge_helpers.rb +11 -5
- data/lib/rhc/cli.rb +4 -2
- data/lib/rhc/command_runner.rb +35 -30
- data/lib/rhc/commands.rb +127 -18
- data/lib/rhc/commands/account.rb +24 -0
- data/lib/rhc/commands/alias.rb +1 -1
- data/lib/rhc/commands/app.rb +210 -209
- data/lib/rhc/commands/apps.rb +22 -0
- data/lib/rhc/commands/base.rb +10 -77
- data/lib/rhc/commands/cartridge.rb +35 -35
- data/lib/rhc/commands/domain.rb +20 -13
- data/lib/rhc/commands/git_clone.rb +30 -0
- data/lib/rhc/commands/{port-forward.rb → port_forward.rb} +3 -3
- data/lib/rhc/commands/server.rb +28 -16
- data/lib/rhc/commands/setup.rb +18 -1
- data/lib/rhc/commands/snapshot.rb +4 -4
- data/lib/rhc/commands/sshkey.rb +4 -18
- data/lib/rhc/commands/tail.rb +32 -9
- data/lib/rhc/config.rb +168 -99
- data/lib/rhc/context_helper.rb +22 -9
- data/lib/rhc/core_ext.rb +41 -1
- data/lib/rhc/exceptions.rb +21 -5
- data/lib/rhc/git_helpers.rb +81 -0
- data/lib/rhc/help_formatter.rb +21 -1
- data/lib/rhc/helpers.rb +222 -87
- data/lib/rhc/output_helpers.rb +94 -110
- data/lib/rhc/rest.rb +15 -198
- data/lib/rhc/rest/api.rb +88 -0
- data/lib/rhc/rest/application.rb +29 -30
- data/lib/rhc/rest/attributes.rb +27 -0
- data/lib/rhc/rest/base.rb +29 -33
- data/lib/rhc/rest/cartridge.rb +42 -20
- data/lib/rhc/rest/client.rb +351 -89
- data/lib/rhc/rest/domain.rb +7 -13
- data/lib/rhc/rest/gear_group.rb +1 -1
- data/lib/rhc/rest/key.rb +7 -2
- data/lib/rhc/rest/mock.rb +609 -0
- data/lib/rhc/rest/user.rb +6 -2
- data/lib/rhc/{ssh_key_helpers.rb → ssh_helpers.rb} +58 -28
- data/lib/rhc/{targz.rb → tar_gz.rb} +0 -0
- data/lib/rhc/usage_templates/command_help.erb +4 -1
- data/lib/rhc/usage_templates/help.erb +24 -11
- data/lib/rhc/usage_templates/options_help.erb +14 -0
- data/lib/rhc/wizard.rb +283 -213
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +3 -371
- data/spec/rhc/auth_spec.rb +226 -0
- data/spec/rhc/cli_spec.rb +41 -14
- data/spec/rhc/command_spec.rb +44 -15
- data/spec/rhc/commands/account_spec.rb +41 -0
- data/spec/rhc/commands/alias_spec.rb +16 -15
- data/spec/rhc/commands/app_spec.rb +115 -92
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/cartridge_spec.rb +134 -112
- data/spec/rhc/commands/domain_spec.rb +31 -86
- data/spec/rhc/commands/git_clone_spec.rb +56 -0
- data/spec/rhc/commands/{port-forward_spec.rb → port_forward_spec.rb} +27 -32
- data/spec/rhc/commands/server_spec.rb +28 -3
- data/spec/rhc/commands/setup_spec.rb +29 -11
- data/spec/rhc/commands/snapshot_spec.rb +4 -3
- data/spec/rhc/commands/sshkey_spec.rb +24 -56
- data/spec/rhc/commands/tail_spec.rb +26 -9
- data/spec/rhc/commands/threaddump_spec.rb +12 -11
- data/spec/rhc/config_spec.rb +211 -164
- data/spec/rhc/context_spec.rb +2 -0
- data/spec/rhc/helpers_spec.rb +242 -46
- data/spec/rhc/rest_application_spec.rb +42 -28
- data/spec/rhc/rest_client_spec.rb +110 -93
- data/spec/rhc/rest_spec.rb +220 -131
- data/spec/rhc/targz_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +435 -624
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +140 -6
- data/spec/wizard_spec_helper.rb +326 -0
- metadata +163 -143
- data/lib/rhc/client.rb +0 -17
- data/lib/rhc/git_helper.rb +0 -59
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/apps'
|
4
|
+
|
5
|
+
describe RHC::Commands::Apps do
|
6
|
+
before{ user_config }
|
7
|
+
let!(:rest_client){ MockRestClient.new }
|
8
|
+
|
9
|
+
describe 'run' do
|
10
|
+
context 'when no domains' do
|
11
|
+
let(:arguments) { ['apps'] }
|
12
|
+
|
13
|
+
it { expect { run }.should exit_with_code(1) }
|
14
|
+
it { run_output.should match(/In order to deploy applications.*rhc domain create/) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with a domain' do
|
18
|
+
let(:arguments){ ['apps'] }
|
19
|
+
let!(:domain){ rest_client.add_domain("first") }
|
20
|
+
|
21
|
+
it { expect { run }.should exit_with_code(1) }
|
22
|
+
it { run_output.should match(/No applications.*rhc app create/) }
|
23
|
+
|
24
|
+
context 'with apps' do
|
25
|
+
let(:arguments) { ['apps'] }
|
26
|
+
before{ domain.add_application('scaled', 'php', true) }
|
27
|
+
|
28
|
+
it { expect { run }.should exit_with_code(0) }
|
29
|
+
it { run_output.should match(/scaled.*\-\-.*php.*Scaling:.*x2 \(minimum/m) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when help is shown' do
|
34
|
+
let(:arguments) { ['apps', '--help'] }
|
35
|
+
it { expect { run }.should exit_with_code(0) }
|
36
|
+
it { run_output.should match(/rhc apps.*Display the list of applications/m) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -22,132 +22,142 @@ describe RHC::Commands::Cartridge do
|
|
22
22
|
exit_with_code_and_message(code)
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
before(:each) do
|
27
|
-
RHC::Config.set_defaults
|
28
|
-
end
|
25
|
+
before{ user_config }
|
29
26
|
|
30
27
|
describe 'run' do
|
31
|
-
let(:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
let!(:rest_client){ MockRestClient.new }
|
29
|
+
context "with all arguments" do
|
30
|
+
let(:arguments) { ['cartridge', '--trace', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
31
|
+
it { succeed_with_message /mock_cart-1.*mock_cart-2.*unique_mock_cart-1/m }
|
32
|
+
end
|
33
|
+
context "without password" do
|
34
|
+
let(:arguments) { ['cartridge', '--trace', '--noprompt', '--config', 'test.conf'] }
|
37
35
|
it { succeed_with_message /mock_cart-1.*mock_cart-2.*unique_mock_cart-1/m }
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
|
-
describe '
|
42
|
-
let(:arguments)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
describe 'cartridge list' do
|
40
|
+
let(:arguments){ ['cartridge', 'list'] }
|
41
|
+
let(:username){ nil }
|
42
|
+
let(:password){ nil }
|
43
|
+
let(:server){ mock_uri }
|
44
|
+
let(:user_auth){ false }
|
45
|
+
|
46
|
+
context 'with valid carts' do
|
47
|
+
before{ stub_api; stub_simple_carts }
|
48
|
+
|
49
|
+
it{ run_output.should match /mock_standalone_cart\-1\s+Mock1 Cart\s+web/ }
|
50
|
+
it{ run_output.should match /mock_standalone_cart\-2\s+web/ }
|
51
|
+
it{ run_output.should match /mock_embedded_cart\-1\s+Mock1 Embedded Cart\s+addon/ }
|
52
|
+
it{ expect{ run }.should exit_with_code(0) }
|
53
|
+
|
54
|
+
context 'with verbose list' do
|
55
|
+
let(:arguments){ ['cartridge', 'list', '--verbose'] }
|
56
|
+
it{ run_output.should match /Mock1 Cart.*\[mock_standalone_cart\-1\] \(web\)/ }
|
57
|
+
it{ run_output.should match /mock_standalone_cart\-2 \(web\)/ }
|
58
|
+
it{ run_output.should match "Mock2 description\n\n" }
|
59
|
+
it{ run_output.should match "Tagged with: scheduled" }
|
60
|
+
it{ run_output.should_not match("Tagged with: cartridge") }
|
47
61
|
end
|
48
|
-
it { succeed_with_message /mock_cart-1.*mock_cart-2.*unique_mock_cart-1/m }
|
49
62
|
end
|
50
63
|
end
|
51
64
|
|
52
65
|
describe 'alias app cartridge' do
|
66
|
+
let!(:rest_client){ MockRestClient.new }
|
53
67
|
let(:arguments) { ['app', 'cartridge', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
54
68
|
|
55
69
|
context 'when run' do
|
56
|
-
before(:each) do
|
57
|
-
@rc = MockRestClient.new
|
58
|
-
end
|
59
70
|
it { succeed_with_message /mock_cart-1.*mock_cart-2.*unique_mock_cart-1/m }
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
63
74
|
describe 'cartridge add' do
|
75
|
+
let!(:rest_client){ MockRestClient.new }
|
64
76
|
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
65
77
|
|
66
78
|
context 'when run' do
|
67
79
|
before(:each) do
|
68
|
-
|
69
|
-
domain = @rc.add_domain("mock_domain")
|
80
|
+
domain = rest_client.add_domain("mock_domain")
|
70
81
|
app = domain.add_application("app1", "mock_type")
|
71
82
|
end
|
72
|
-
it {
|
73
|
-
|
74
|
-
}
|
83
|
+
it { succeed_with_message /Adding mock_cart-1 to application 'app1' \.\.\. / }
|
84
|
+
it { succeed_with_message /Connection URL:\s+http\:\/\/fake\.url/ }
|
85
|
+
it { succeed_with_message /Prop1:\s+value1/ }
|
86
|
+
it { succeed_with_message /Cartridge added with properties/ }
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
78
|
-
describe 'cartridge add
|
79
|
-
let(:
|
90
|
+
describe 'cartridge add' do
|
91
|
+
let!(:rest_client){ MockRestClient.new }
|
92
|
+
let(:instance) do
|
93
|
+
domain = rest_client.add_domain("mock_domain")
|
94
|
+
@app = domain.add_application("app1", "mock_type")
|
95
|
+
instance = RHC::Commands::Cartridge.new
|
96
|
+
RHC::Commands::Cartridge.stub(:new) { instance }
|
97
|
+
instance
|
98
|
+
end
|
80
99
|
|
81
|
-
context '
|
100
|
+
context 'with app context' do
|
101
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
82
102
|
before(:each) do
|
83
|
-
@
|
84
|
-
domain = @rc.add_domain("mock_domain")
|
85
|
-
app = domain.add_application("app1", "mock_type")
|
86
|
-
instance = RHC::Commands::Cartridge.new
|
87
|
-
instance.stub(:git_config_get) { |key| app.uuid if key == "rhc.app-uuid" }
|
88
|
-
RHC::Commands::Cartridge.stub(:new) { instance }
|
103
|
+
instance.stub(:git_config_get) { |key| @app.uuid if key == "rhc.app-uuid" }
|
89
104
|
end
|
90
|
-
it
|
91
|
-
succeed_with_message
|
92
|
-
}
|
105
|
+
it{ succeed_with_message }
|
93
106
|
end
|
94
|
-
end
|
95
107
|
|
96
|
-
|
97
|
-
|
108
|
+
context 'with named app context' do
|
109
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
110
|
+
before(:each) do
|
111
|
+
instance.stub(:git_config_get) { |key| @app.name if key == "rhc.app-name" }
|
112
|
+
end
|
113
|
+
it{ succeed_with_message }
|
114
|
+
end
|
98
115
|
|
99
|
-
context '
|
116
|
+
context 'without app context' do
|
117
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
100
118
|
before(:each) do
|
101
|
-
|
102
|
-
|
103
|
-
app = domain.add_application("app1", "mock_type")
|
104
|
-
instance = RHC::Commands::Cartridge.new
|
105
|
-
instance.stub(:git_config_get) { |key| "" if key == "rhc.app-uuid" }
|
106
|
-
RHC::Commands::Cartridge.stub(:new) { instance }
|
119
|
+
instance.should_receive(:git_config_get).with('rhc.app-name').and_return(nil)
|
120
|
+
instance.should_receive(:git_config_get).with('rhc.app-uuid').and_return('')
|
107
121
|
end
|
108
|
-
it
|
109
|
-
|
110
|
-
|
122
|
+
it{ fail_with_code }
|
123
|
+
end
|
124
|
+
context 'without missing app context' do
|
125
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
126
|
+
before(:each) do
|
127
|
+
instance.should_receive(:git_config_get).with('rhc.app-name').and_return(nil)
|
128
|
+
instance.should_receive(:git_config_get).with('rhc.app-uuid').and_return('foo')
|
129
|
+
end
|
130
|
+
it{ fail_with_code }
|
111
131
|
end
|
112
132
|
end
|
113
133
|
|
114
|
-
describe '
|
115
|
-
let(:
|
134
|
+
describe 'cartridge add' do
|
135
|
+
let!(:rest_client){ MockRestClient.new }
|
116
136
|
|
117
|
-
context 'when
|
137
|
+
context 'when invoked through an alias' do
|
138
|
+
let(:arguments) { ['app', 'cartridge', 'add', 'unique_mock_cart', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
118
139
|
before(:each) do
|
119
|
-
|
120
|
-
domain = @rc.add_domain("mock_domain")
|
140
|
+
domain = rest_client.add_domain("mock_domain")
|
121
141
|
app = domain.add_application("app1", "mock_type")
|
122
142
|
end
|
123
143
|
it {
|
124
144
|
succeed_with_message
|
125
145
|
}
|
126
146
|
end
|
127
|
-
end
|
128
147
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
context 'when run' do
|
148
|
+
context 'when cartridge does not exist' do
|
149
|
+
let(:arguments) { ['cartridge', 'add', 'nomatch_cart', '--app', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
133
150
|
before(:each) do
|
134
|
-
|
135
|
-
domain = @rc.add_domain("mock_domain")
|
151
|
+
domain = rest_client.add_domain("mock_domain")
|
136
152
|
app = domain.add_application("app1", "mock_type")
|
137
153
|
end
|
138
|
-
it
|
139
|
-
fail_with_code 154
|
140
|
-
}
|
154
|
+
it{ fail_with_code 154 }
|
141
155
|
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe 'cartridge add too many carts found error' do
|
145
|
-
let(:arguments) { ['cartridge', 'add', 'mock_cart', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
146
156
|
|
147
|
-
context 'when
|
157
|
+
context 'when multiple carts match' do
|
158
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
148
159
|
before(:each) do
|
149
|
-
|
150
|
-
domain = @rc.add_domain("mock_domain")
|
160
|
+
domain = rest_client.add_domain("mock_domain")
|
151
161
|
app = domain.add_application("app1", "mock_type")
|
152
162
|
end
|
153
163
|
it {
|
@@ -156,29 +166,24 @@ describe RHC::Commands::Cartridge do
|
|
156
166
|
end
|
157
167
|
end
|
158
168
|
|
159
|
-
describe 'cartridge remove
|
160
|
-
let(:
|
169
|
+
describe 'cartridge remove' do
|
170
|
+
let!(:rest_client){ MockRestClient.new }
|
161
171
|
|
162
|
-
context 'when run' do
|
172
|
+
context 'when run with --noprompt and without --confirm' do
|
173
|
+
let(:arguments) { ['cartridge', 'remove', 'mock_cart-1', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
163
174
|
before(:each) do
|
164
|
-
|
165
|
-
domain = @rc.add_domain("mock_domain")
|
175
|
+
domain = rest_client.add_domain("mock_domain")
|
166
176
|
app = domain.add_application("app1", "mock_type")
|
167
177
|
app.add_cartridge('mock_cart-1')
|
168
178
|
end
|
169
|
-
it {
|
170
|
-
fail_with_message "Removing a cartridge is a destructive operation"
|
171
|
-
}
|
172
|
-
end
|
173
|
-
end
|
174
179
|
|
175
|
-
|
176
|
-
|
180
|
+
it{ fail_with_message "This action requires the --confirm option" }
|
181
|
+
end
|
177
182
|
|
178
|
-
context 'when run' do
|
183
|
+
context 'when run with confirmation' do
|
184
|
+
let(:arguments) { ['cartridge', 'remove', 'mock_cart-1', '--confirm', '--trace', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
179
185
|
before(:each) do
|
180
|
-
|
181
|
-
domain = @rc.add_domain("mock_domain")
|
186
|
+
domain = rest_client.add_domain("mock_domain")
|
182
187
|
@app = domain.add_application("app1", "mock_type")
|
183
188
|
end
|
184
189
|
it "should remove cartridge" do
|
@@ -194,11 +199,11 @@ describe RHC::Commands::Cartridge do
|
|
194
199
|
end
|
195
200
|
|
196
201
|
describe 'cartridge status' do
|
202
|
+
let!(:rest_client){ MockRestClient.new }
|
197
203
|
let(:arguments) { ['cartridge', 'status', 'mock_cart-1', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
198
204
|
|
199
205
|
before(:each) do
|
200
|
-
@
|
201
|
-
@domain = @rc.add_domain("mock_domain")
|
206
|
+
@domain = rest_client.add_domain("mock_domain")
|
202
207
|
@app = @domain.add_application("app1", "mock_type")
|
203
208
|
@app.add_cartridge('mock_cart-1')
|
204
209
|
end
|
@@ -214,12 +219,12 @@ describe RHC::Commands::Cartridge do
|
|
214
219
|
end
|
215
220
|
|
216
221
|
describe 'cartridge start' do
|
222
|
+
let!(:rest_client){ MockRestClient.new }
|
217
223
|
let(:arguments) { ['cartridge', 'start', 'mock_cart-1', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
218
224
|
|
219
225
|
context 'when run' do
|
220
226
|
before(:each) do
|
221
|
-
|
222
|
-
domain = @rc.add_domain("mock_domain")
|
227
|
+
domain = rest_client.add_domain("mock_domain")
|
223
228
|
app = domain.add_application("app1", "mock_type")
|
224
229
|
app.add_cartridge('mock_cart-1')
|
225
230
|
end
|
@@ -228,12 +233,12 @@ describe RHC::Commands::Cartridge do
|
|
228
233
|
end
|
229
234
|
|
230
235
|
describe 'cartridge stop' do
|
236
|
+
let!(:rest_client){ MockRestClient.new }
|
231
237
|
let(:arguments) { ['cartridge', 'stop', 'mock_cart-1', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
232
238
|
|
233
239
|
context 'when run' do
|
234
240
|
before(:each) do
|
235
|
-
|
236
|
-
domain = @rc.add_domain("mock_domain")
|
241
|
+
domain = rest_client.add_domain("mock_domain")
|
237
242
|
app = domain.add_application("app1", "mock_type")
|
238
243
|
app.add_cartridge('mock_cart-1')
|
239
244
|
end
|
@@ -242,12 +247,12 @@ describe RHC::Commands::Cartridge do
|
|
242
247
|
end
|
243
248
|
|
244
249
|
describe 'cartridge restart' do
|
250
|
+
let!(:rest_client){ MockRestClient.new }
|
245
251
|
let(:arguments) { ['cartridge', 'restart', 'mock_cart-1', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
246
252
|
|
247
253
|
context 'when run' do
|
248
254
|
before(:each) do
|
249
|
-
|
250
|
-
domain = @rc.add_domain("mock_domain")
|
255
|
+
domain = rest_client.add_domain("mock_domain")
|
251
256
|
app = domain.add_application("app1", "mock_type")
|
252
257
|
app.add_cartridge('mock_cart-1')
|
253
258
|
end
|
@@ -256,12 +261,12 @@ describe RHC::Commands::Cartridge do
|
|
256
261
|
end
|
257
262
|
|
258
263
|
describe 'cartridge reload' do
|
264
|
+
let!(:rest_client){ MockRestClient.new }
|
259
265
|
let(:arguments) { ['cartridge', 'reload', 'mock_cart-1', '-a', 'app1','--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
260
266
|
|
261
267
|
context 'when run' do
|
262
268
|
before(:each) do
|
263
|
-
|
264
|
-
domain = @rc.add_domain("mock_domain")
|
269
|
+
domain = rest_client.add_domain("mock_domain")
|
265
270
|
app = domain.add_application("app1", "mock_type")
|
266
271
|
app.add_cartridge('mock_cart-1')
|
267
272
|
end
|
@@ -270,8 +275,24 @@ describe RHC::Commands::Cartridge do
|
|
270
275
|
end
|
271
276
|
|
272
277
|
describe 'cartridge show' do
|
278
|
+
let!(:rest_client){ MockRestClient.new }
|
273
279
|
let(:arguments) { ['cartridge', 'show', 'mock_cart-1', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
274
280
|
|
281
|
+
before(:each) do
|
282
|
+
domain = rest_client.add_domain("mock_domain")
|
283
|
+
app = domain.add_application("app1", "mock_type")
|
284
|
+
app.add_cartridge('mock_cart-1')
|
285
|
+
end
|
286
|
+
|
287
|
+
context 'when run with exactly the same case as how cartridge was created' do
|
288
|
+
it { run_output.should match('Connection URL: http://fake.url') }
|
289
|
+
it { run_output.should match(/Prop1:\s+value1/) }
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe 'cartridge show' do
|
294
|
+
let(:arguments) { ['cartridge', 'show', 'Mock_Cart-1', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
295
|
+
|
275
296
|
before(:each) do
|
276
297
|
@rc = MockRestClient.new
|
277
298
|
domain = @rc.add_domain("mock_domain")
|
@@ -279,34 +300,36 @@ describe RHC::Commands::Cartridge do
|
|
279
300
|
app.add_cartridge('mock_cart-1')
|
280
301
|
end
|
281
302
|
|
282
|
-
context 'when run' do
|
283
|
-
it { run_output.should match('Connection URL
|
303
|
+
context 'when run with different case from how cartrige was created' do
|
304
|
+
it { run_output.should match('Connection URL: http://fake.url') }
|
305
|
+
it { run_output.should match(/Prop1:\s+value1/) }
|
284
306
|
end
|
285
307
|
end
|
286
308
|
|
287
309
|
describe 'cartridge show scaled' do
|
310
|
+
let!(:rest_client){ MockRestClient.new }
|
288
311
|
let(:arguments) { ['cartridge', 'show', 'mock_type', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
289
312
|
|
290
313
|
context 'when run' do
|
291
314
|
before(:each) do
|
292
|
-
|
293
|
-
domain = @rc.add_domain("mock_domain")
|
315
|
+
domain = rest_client.add_domain("mock_domain")
|
294
316
|
app = domain.add_application("app1", "mock_type", true)
|
295
317
|
end
|
296
|
-
it { run_output.should match(
|
297
|
-
it { run_output.should match('
|
298
|
-
it { run_output.should match('
|
299
|
-
it { run_output.should match('Maximum = available gears') }
|
318
|
+
it { run_output.should match(/Scaling: .*x2 \(minimum/) }
|
319
|
+
it { run_output.should match('minimum: 2') }
|
320
|
+
it { run_output.should match('maximum: available') }
|
300
321
|
end
|
301
322
|
end
|
302
323
|
|
303
324
|
describe 'cartridge scale' do
|
325
|
+
let!(:rest_client){ MockRestClient.new }
|
304
326
|
let(:arguments) { ['cartridge', 'scale', @cart_type || 'mock_type', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] | (@extra_args || []) }
|
305
327
|
|
328
|
+
let(:current_scale) { 1 }
|
306
329
|
before(:each) do
|
307
|
-
|
308
|
-
domain = @rc.add_domain("mock_domain")
|
330
|
+
domain = rest_client.add_domain("mock_domain")
|
309
331
|
app = domain.add_application("app1", "mock_type", scalable)
|
332
|
+
app.cartridges.first.stub(:current_scale).and_return(current_scale)
|
310
333
|
end
|
311
334
|
|
312
335
|
context 'when run with scalable app' do
|
@@ -318,12 +341,12 @@ describe RHC::Commands::Cartridge do
|
|
318
341
|
|
319
342
|
it "with a min value" do
|
320
343
|
@extra_args = ["--min","6"]
|
321
|
-
succeed_with_message "
|
344
|
+
succeed_with_message "minimum: 6"
|
322
345
|
end
|
323
346
|
|
324
347
|
it "with a max value" do
|
325
348
|
@extra_args = ["--max","3"]
|
326
|
-
succeed_with_message '
|
349
|
+
succeed_with_message 'maximum: 3'
|
327
350
|
end
|
328
351
|
|
329
352
|
it "with an invalid min value" do
|
@@ -355,10 +378,9 @@ describe RHC::Commands::Cartridge do
|
|
355
378
|
let(:cart_type) { ['mock_cart-1'] }
|
356
379
|
|
357
380
|
before(:each) do
|
358
|
-
|
359
|
-
domain = @rc.add_domain("mock_domain")
|
381
|
+
domain = rest_client.add_domain("mock_domain")
|
360
382
|
app = domain.add_application("app1", "mock_type", false)
|
361
|
-
app.add_cartridge('mock_cart-1', true
|
383
|
+
app.add_cartridge('mock_cart-1', true)
|
362
384
|
end
|
363
385
|
|
364
386
|
context 'when run with no arguments' do
|