rhc 1.2.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -2,16 +2,17 @@ require 'spec_helper'
|
|
2
2
|
require 'rest_spec_helper'
|
3
3
|
require 'rhc/commands/alias'
|
4
4
|
require 'rhc/config'
|
5
|
+
|
5
6
|
describe RHC::Commands::Alias do
|
6
7
|
let(:client_links) { mock_response_links(mock_client_links) }
|
7
8
|
let(:domain_0_links) { mock_response_links(mock_domain_links('mock_domain_0')) }
|
8
9
|
let(:domain_1_links) { mock_response_links(mock_domain_links('mock_domain_1')) }
|
9
10
|
let(:app_0_links) { mock_response_links(mock_app_links('mock_domain_0', 'mock_app_0')) }
|
11
|
+
let!(:rest_client){ MockRestClient.new }
|
10
12
|
before(:each) do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).with(:headers => {'Accept-Encoding'=>'gzip, deflate'}).
|
13
|
+
user_config
|
14
|
+
rest_client.add_domain("mock_domain_0").add_application("mock_app_0", "ruby-1.8.7")
|
15
|
+
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).
|
15
16
|
to_return({ :body => {
|
16
17
|
:type => 'domains',
|
17
18
|
:data =>
|
@@ -24,7 +25,7 @@ describe RHC::Commands::Alias do
|
|
24
25
|
}.to_json,
|
25
26
|
:status => 200
|
26
27
|
})
|
27
|
-
stub_api_request(:any, domain_0_links['LIST_APPLICATIONS']['relative']).
|
28
|
+
stub_api_request(:any, domain_0_links['LIST_APPLICATIONS']['relative']).
|
28
29
|
to_return({ :body => {
|
29
30
|
:type => 'applications',
|
30
31
|
:data =>
|
@@ -39,7 +40,8 @@ describe RHC::Commands::Alias do
|
|
39
40
|
}.to_json,
|
40
41
|
:status => 200
|
41
42
|
})
|
42
|
-
stub_api_request(:any, app_0_links['ADD_ALIAS']['relative']
|
43
|
+
stub_api_request(:any, app_0_links['ADD_ALIAS']['relative'], false).
|
44
|
+
with(:body => {:event => 'add-alias', :alias => 'www.foo.bar'}).
|
43
45
|
to_return({ :body => {
|
44
46
|
:type => 'application',
|
45
47
|
:data =>
|
@@ -55,7 +57,8 @@ describe RHC::Commands::Alias do
|
|
55
57
|
}.to_json,
|
56
58
|
:status => 200
|
57
59
|
})
|
58
|
-
stub_api_request(:any, app_0_links['REMOVE_ALIAS']['relative']
|
60
|
+
stub_api_request(:any, app_0_links['REMOVE_ALIAS']['relative'], false).
|
61
|
+
with(:body => {:event => 'remove-alias', :alias => 'www.foo.bar'}).
|
59
62
|
to_return({ :body => {
|
60
63
|
:type => 'application',
|
61
64
|
:data =>
|
@@ -108,16 +111,14 @@ stub_api_request(:any, app_0_links['REMOVE_ALIAS']['relative']).with(:body => {:
|
|
108
111
|
end
|
109
112
|
|
110
113
|
describe 'add alias' do
|
111
|
-
let(:arguments) { ['alias', 'add', 'mock_app_0', 'www.foo.bar'
|
112
|
-
|
113
|
-
|
114
|
-
end
|
114
|
+
let(:arguments) { ['alias', 'add', 'mock_app_0', 'www.foo.bar' ] }
|
115
|
+
it { expect { run }.should exit_with_code(0) }
|
116
|
+
it { run_output.should =~ /'add-alias' successful/m }
|
115
117
|
end
|
116
118
|
|
117
119
|
describe 'remove alias' do
|
118
|
-
let(:arguments) { ['alias', 'remove', 'mock_app_0', 'www.foo.bar'
|
119
|
-
|
120
|
-
|
121
|
-
end
|
120
|
+
let(:arguments) { ['alias', 'remove', 'mock_app_0', 'www.foo.bar' ] }
|
121
|
+
it { expect { run }.should exit_with_code(0) }
|
122
|
+
it { run_output.should =~ /'remove-alias' successful/m }
|
122
123
|
end
|
123
124
|
end
|
@@ -4,11 +4,13 @@ require 'rhc/commands/app'
|
|
4
4
|
require 'rhc/config'
|
5
5
|
|
6
6
|
describe RHC::Commands::App do
|
7
|
+
let!(:rest_client){ MockRestClient.new }
|
7
8
|
before(:each) do
|
8
9
|
FakeFS.activate!
|
9
10
|
FakeFS::FileSystem.clear
|
10
|
-
|
11
|
-
RHC::Helpers::MAX_RETRIES
|
11
|
+
user_config
|
12
|
+
RHC::Helpers::remove_const(:MAX_RETRIES) rescue nil
|
13
|
+
RHC::Helpers::const_set(:MAX_RETRIES, 3)
|
12
14
|
@instance = RHC::Commands::App.new
|
13
15
|
RHC::Commands::App.stub(:new) do
|
14
16
|
@instance.stub(:git_config_get) { "" }
|
@@ -32,7 +34,6 @@ describe RHC::Commands::App do
|
|
32
34
|
describe 'app default' do
|
33
35
|
before(:each) do
|
34
36
|
FakeFS.deactivate!
|
35
|
-
@rc = MockRestClient.new
|
36
37
|
end
|
37
38
|
|
38
39
|
context 'app' do
|
@@ -43,8 +44,7 @@ describe RHC::Commands::App do
|
|
43
44
|
|
44
45
|
describe 'app create' do
|
45
46
|
before(:each) do
|
46
|
-
|
47
|
-
domain = @rc.add_domain("mockdomain")
|
47
|
+
domain = rest_client.add_domain("mockdomain")
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when run without a cart' do
|
@@ -57,21 +57,39 @@ describe RHC::Commands::App do
|
|
57
57
|
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--noprompt', '--timeout', '10', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
58
58
|
it { expect { run }.should exit_with_code(0) }
|
59
59
|
it { run_output.should match("Success") }
|
60
|
+
it { run_output.should match("Cartridges: mock_standalone_cart-1\n") }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when run with multiple carts' do
|
64
|
+
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', 'mock_cart-1', '--noprompt', '-p', 'password'] }
|
65
|
+
it { expect { run }.should exit_with_code(0) }
|
66
|
+
it { run_output.should match("Success") }
|
67
|
+
it { run_output.should match("Cartridges: mock_standalone_cart-1, mock_cart-1\n") }
|
68
|
+
after{ rest_client.domains.first.applications.first.cartridges.find{ |c| c.name == 'mock_cart-1' }.should be_true }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when run with a git url' do
|
72
|
+
let(:arguments) { ['app', 'create', 'app1', 'mock_standalone_cart-1', '--from', 'git://url', '--noprompt', '-p', 'password'] }
|
73
|
+
it { expect { run }.should exit_with_code(0) }
|
74
|
+
it { run_output.should match("Success") }
|
75
|
+
it { run_output.should match("Source Code: git://url\n") }
|
76
|
+
it { run_output.should match("Initial Git URL: git://url\n") }
|
77
|
+
after{ rest_client.domains.first.applications.first.initial_git_url.should == 'git://url' }
|
60
78
|
end
|
61
79
|
|
62
80
|
context 'when no cartridges are returned' do
|
63
81
|
before(:each) do
|
64
|
-
domain =
|
65
|
-
|
66
|
-
domain.stub(:add_application).and_raise(RHC::Rest::ValidationException.new('Each application needs a web cartridge', '', '109'))
|
82
|
+
domain = rest_client.domains.first
|
83
|
+
#rest_client.stub(:cartridges) { [] }
|
84
|
+
# domain.stub(:add_application).and_raise(RHC::Rest::ValidationException.new('Each application needs a web cartridge', '', '109'))
|
67
85
|
end
|
68
86
|
context 'without trace' do
|
69
87
|
let(:arguments) { ['app', 'create', 'app1', 'nomatch_cart', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
70
|
-
it { run_output.should match(/
|
88
|
+
it("should display the list of cartridges") { run_output.should match(/Short Name.*mock_standalone_cart-2/m) }
|
71
89
|
end
|
72
90
|
context 'with trace' do
|
73
91
|
let(:arguments) { ['app', 'create', 'app1', 'nomatch_cart', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--trace'] }
|
74
|
-
it { expect { run }.should raise_error(RHC::
|
92
|
+
it { expect { run }.should raise_error(RHC::CartridgeNotFoundException, "There are no cartridges that match 'nomatch_cart'.") }
|
75
93
|
end
|
76
94
|
end
|
77
95
|
end
|
@@ -81,8 +99,7 @@ describe RHC::Commands::App do
|
|
81
99
|
|
82
100
|
context 'when run' do
|
83
101
|
before(:each) do
|
84
|
-
|
85
|
-
domain = @rc.add_domain("mockdomain")
|
102
|
+
domain = rest_client.add_domain("mockdomain")
|
86
103
|
end
|
87
104
|
it { expect { run }.should raise_error(RHC::MultipleCartridgesException) }
|
88
105
|
end
|
@@ -93,10 +110,10 @@ describe RHC::Commands::App do
|
|
93
110
|
|
94
111
|
context 'when run' do
|
95
112
|
before(:each) do
|
96
|
-
@
|
97
|
-
@domain = @rc.add_domain("mockdomain")
|
113
|
+
@domain = rest_client.add_domain("mockdomain")
|
98
114
|
end
|
99
115
|
it "should create a jenkins app and a regular app with an embedded jenkins client" do
|
116
|
+
#puts run_output
|
100
117
|
expect { run }.should exit_with_code(0)
|
101
118
|
jenkins_app = @domain.find_application("jenkins")
|
102
119
|
jenkins_app.cartridges[0].name.should == "jenkins-1.4"
|
@@ -111,10 +128,9 @@ describe RHC::Commands::App do
|
|
111
128
|
|
112
129
|
context 'when run' do
|
113
130
|
before(:each) do
|
114
|
-
|
115
|
-
domain = @rc.add_domain("mockdomain")
|
131
|
+
domain = rest_client.add_domain("mockdomain")
|
116
132
|
end
|
117
|
-
it { expect { run }.
|
133
|
+
it { expect { run }.should_not raise_error(ArgumentError, /The --no-dns option can't be used in conjunction with --enable-jenkins/) }
|
118
134
|
end
|
119
135
|
end
|
120
136
|
|
@@ -123,8 +139,7 @@ describe RHC::Commands::App do
|
|
123
139
|
|
124
140
|
context 'when run' do
|
125
141
|
before(:each) do
|
126
|
-
|
127
|
-
domain = @rc.add_domain("mockdomain")
|
142
|
+
domain = rest_client.add_domain("mockdomain")
|
128
143
|
end
|
129
144
|
it { expect { run }.should raise_error(ArgumentError, /You have named both your main application and your Jenkins application/) }
|
130
145
|
end
|
@@ -135,8 +150,7 @@ describe RHC::Commands::App do
|
|
135
150
|
|
136
151
|
context 'when run' do
|
137
152
|
before(:each) do
|
138
|
-
@
|
139
|
-
@domain = @rc.add_domain("mockdomain")
|
153
|
+
@domain = rest_client.add_domain("mockdomain")
|
140
154
|
@domain.add_application("jenkins", "jenkins-1.4")
|
141
155
|
end
|
142
156
|
it "should use existing jenkins" do
|
@@ -147,30 +161,16 @@ describe RHC::Commands::App do
|
|
147
161
|
end
|
148
162
|
end
|
149
163
|
|
150
|
-
describe 'app create enable-jenkins named after existing app' do
|
151
|
-
let(:arguments) { ['app', 'create', 'app1', 'mock_unique_standalone_cart', '--trace', '--enable-jenkins', 'app2', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
152
|
-
|
153
|
-
context 'when run' do
|
154
|
-
before(:each) do
|
155
|
-
@rc = MockRestClient.new
|
156
|
-
domain = @rc.add_domain("mockdomain")
|
157
|
-
domain.add_application("app2", "mock_unique_standalone_cart")
|
158
|
-
end
|
159
|
-
it { expect { run }.should raise_error(ArgumentError, /You have named your Jenkins application the same as an existing application/) }
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
164
|
describe 'app create jenkins fails to install warnings' do
|
164
165
|
let(:arguments) { ['app', 'create', 'app1', 'mock_unique_standalone_cart', '--enable-jenkins', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
165
166
|
|
166
167
|
before(:each) do
|
167
|
-
@
|
168
|
-
@domain = @rc.add_domain("mockdomain")
|
168
|
+
@domain = rest_client.add_domain("mockdomain")
|
169
169
|
end
|
170
170
|
|
171
171
|
context 'when run with error in jenkins setup' do
|
172
172
|
before(:each) do
|
173
|
-
@instance.stub(:
|
173
|
+
@instance.stub(:add_jenkins_app) { raise Exception }
|
174
174
|
end
|
175
175
|
it "should print out jenkins warning" do
|
176
176
|
run_output.should match("Jenkins failed to install")
|
@@ -179,7 +179,7 @@ describe RHC::Commands::App do
|
|
179
179
|
|
180
180
|
context 'when run with error in jenkins-client setup' do
|
181
181
|
before(:each) do
|
182
|
-
@instance.stub(:
|
182
|
+
@instance.stub(:add_jenkins_cartridge) { raise Exception }
|
183
183
|
end
|
184
184
|
it "should print out jenkins warning" do
|
185
185
|
run_output.should match("Jenkins client failed to install")
|
@@ -192,9 +192,8 @@ describe RHC::Commands::App do
|
|
192
192
|
|
193
193
|
context 'when run with server error in jenkins-client setup' do
|
194
194
|
before(:each) do
|
195
|
-
@
|
196
|
-
@
|
197
|
-
@instance.stub(:setup_jenkins_client) { raise RHC::Rest::ServerErrorException.new("Server error", 157) }
|
195
|
+
@domain = rest_client.add_domain("mockdomain")
|
196
|
+
@instance.stub(:add_jenkins_cartridge) { raise RHC::Rest::ServerErrorException.new("Server error", 157) }
|
198
197
|
end
|
199
198
|
it "should fail embedding jenkins cartridge" do
|
200
199
|
Kernel.should_receive(:sleep).and_return(true)
|
@@ -208,8 +207,7 @@ describe RHC::Commands::App do
|
|
208
207
|
|
209
208
|
context 'when run' do
|
210
209
|
before(:each) do
|
211
|
-
@
|
212
|
-
@domain = @rc.add_domain("dnserror")
|
210
|
+
@domain = rest_client.add_domain("dnserror")
|
213
211
|
end
|
214
212
|
it { run_output.should match("unable to lookup your hostname") }
|
215
213
|
end
|
@@ -219,9 +217,9 @@ describe RHC::Commands::App do
|
|
219
217
|
let(:arguments) { ['app', 'create', 'app1', 'mock_unique_standalone_cart', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
220
218
|
|
221
219
|
before(:each) do
|
222
|
-
@
|
223
|
-
@
|
224
|
-
@instance.
|
220
|
+
@domain = rest_client.add_domain("mockdomain")
|
221
|
+
@instance.stub(:git_clone_application) { raise RHC::GitException }
|
222
|
+
@instance.should_not_receive(:check_sshkeys!)
|
225
223
|
end
|
226
224
|
|
227
225
|
context 'when run with error in git clone' do
|
@@ -257,8 +255,7 @@ describe RHC::Commands::App do
|
|
257
255
|
let(:arguments) { ['app', 'create', 'app1', 'mock_unique_standalone_cart', '--noprompt', '--nogit', '--config', '/tmp/test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
258
256
|
|
259
257
|
before (:each) do
|
260
|
-
@
|
261
|
-
@domain = @rc.add_domain("mockdomain")
|
258
|
+
@domain = rest_client.add_domain("mockdomain")
|
262
259
|
end
|
263
260
|
|
264
261
|
context 'when run' do
|
@@ -270,8 +267,7 @@ describe RHC::Commands::App do
|
|
270
267
|
let(:arguments) { ['app', 'create', 'app1', 'mock_unique_standalone_cart', '--config', '/tmp/test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
271
268
|
|
272
269
|
before (:each) do
|
273
|
-
@
|
274
|
-
@domain = @rc.add_domain("mockdomain")
|
270
|
+
@domain = rest_client.add_domain("mockdomain")
|
275
271
|
# fakefs is activated
|
276
272
|
Dir.mkdir('/tmp/')
|
277
273
|
File.open('/tmp/test.conf', 'w') do |f|
|
@@ -279,7 +275,7 @@ describe RHC::Commands::App do
|
|
279
275
|
end
|
280
276
|
|
281
277
|
# don't run wizard here because we test this elsewhere
|
282
|
-
wizard_instance = RHC::SSHWizard.new(
|
278
|
+
wizard_instance = RHC::SSHWizard.new(rest_client, RHC::Config.new, Commander::Command::Options.new)
|
283
279
|
wizard_instance.stub(:ssh_key_uploaded?) { true }
|
284
280
|
RHC::SSHWizard.stub(:new) { wizard_instance }
|
285
281
|
RHC::Config.stub(:should_run_ssh_wizard?) { false }
|
@@ -290,65 +286,86 @@ describe RHC::Commands::App do
|
|
290
286
|
end
|
291
287
|
end
|
292
288
|
|
293
|
-
describe 'app git-clone' do
|
294
|
-
let(:arguments) { ['app', 'git-clone', '--trace', '-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
295
|
-
|
296
|
-
context 'when run' do
|
297
|
-
before(:each) do
|
298
|
-
@rc = MockRestClient.new
|
299
|
-
@domain = @rc.add_domain("mockdomain")
|
300
|
-
@app = @domain.add_application("app1", "mock_unique_standalone_cart")
|
301
|
-
end
|
302
|
-
it { expect { run }.should exit_with_code(0) }
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
289
|
describe 'app delete' do
|
307
|
-
let(:arguments) { ['app', 'delete', '--trace', '-a', 'app1', '--
|
290
|
+
let(:arguments) { ['app', 'delete', '--trace', '-a', 'app1', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
308
291
|
|
309
292
|
context 'when run' do
|
310
|
-
before(
|
311
|
-
@rc = MockRestClient.new
|
312
|
-
@domain = @rc.add_domain("mockdomain")
|
313
|
-
end
|
314
|
-
it "should not remove app when no is sent as input" do
|
315
|
-
@app = @domain.add_application("app1", "mock_type")
|
316
|
-
expect { run(["no"]) }.should exit_with_code(0)
|
317
|
-
@domain.applications.length.should == 1
|
318
|
-
@domain.applications[0] == @app
|
319
|
-
end
|
293
|
+
before{ @domain = rest_client.add_domain("mockdomain") }
|
320
294
|
|
321
|
-
it "should remove app when yes is sent as input" do
|
322
|
-
@app = @domain.add_application("app1", "mock_type")
|
323
|
-
expect { run(["yes"]) }.should exit_with_code(0)
|
324
|
-
@domain.applications.length.should == 0
|
325
|
-
end
|
326
295
|
it "should raise cartridge not found exception when no apps exist" do
|
327
296
|
expect { run }.should raise_error RHC::ApplicationNotFoundException
|
328
297
|
end
|
298
|
+
|
299
|
+
context "with an app" do
|
300
|
+
before{ @app = @domain.add_application("app1", "mock_type") }
|
301
|
+
|
302
|
+
it "should not remove app when no is sent as input" do
|
303
|
+
expect { run(["no"]) }.should raise_error(RHC::ConfirmationError)
|
304
|
+
@domain.applications.length.should == 1
|
305
|
+
@domain.applications[0] == @app
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should remove app when yes is sent as input" do
|
309
|
+
expect { run(["yes"]) }.should exit_with_code(0)
|
310
|
+
@domain.applications.length.should == 0
|
311
|
+
end
|
312
|
+
|
313
|
+
context "with --noprompt but without --confirm" do
|
314
|
+
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--trace'] }
|
315
|
+
it "should not remove the app" do
|
316
|
+
expect { run(["no"]) }.should raise_error(RHC::ConfirmationError)
|
317
|
+
@domain.applications.length.should == 1
|
318
|
+
end
|
319
|
+
end
|
320
|
+
context "with --noprompt and --confirm" do
|
321
|
+
let(:arguments) { ['app', 'delete', 'app1', '--noprompt', '--confirm'] }
|
322
|
+
it "should remove the app" do
|
323
|
+
expect { run }.should exit_with_code(0)
|
324
|
+
@domain.applications.length.should == 0
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
329
328
|
end
|
330
329
|
end
|
331
330
|
|
332
331
|
describe 'app show' do
|
333
332
|
let(:arguments) { ['app', 'show', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
334
333
|
|
335
|
-
context 'when run' do
|
334
|
+
context 'when run with the same case as created' do
|
336
335
|
before(:each) do
|
337
|
-
|
338
|
-
@domain =
|
336
|
+
FakeFS.deactivate!
|
337
|
+
@domain = rest_client.add_domain("mockdomain")
|
339
338
|
@domain.add_application("app1", "mock_type")
|
340
339
|
end
|
341
|
-
it { run_output.should match("app1 @ https://app1-mockdomain.fake.foo/") }
|
340
|
+
it("should output an app") { run_output.should match("app1 @ https://app1-mockdomain.fake.foo/") }
|
341
|
+
it { run_output.should match(/Gears:\s+1 small/) }
|
342
342
|
end
|
343
343
|
|
344
344
|
context 'when run with scaled app' do
|
345
|
+
before(:each) do
|
346
|
+
@domain = rest_client.add_domain("mockdomain")
|
347
|
+
app = @domain.add_application("app1", "mock_type", true)
|
348
|
+
cart1 = app.add_cartridge('mock_cart-1')
|
349
|
+
cart2 = app.add_cartridge('mock_cart-2')
|
350
|
+
cart2.gear_profile = 'medium'
|
351
|
+
end
|
352
|
+
it { run_output.should match("app1 @ https://app1-mockdomain.fake.foo/") }
|
353
|
+
it { run_output.should match(/Scaling:.*x2/) }
|
354
|
+
it { run_output.should match(/Gears:\s+Located with mock_type/) }
|
355
|
+
it { run_output.should match(/Gears:\s+1 medium/) }
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
describe 'app show' do
|
360
|
+
let(:arguments) { ['app', 'show', 'APP1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
361
|
+
|
362
|
+
context 'when run with the different case from created' do
|
345
363
|
before(:each) do
|
346
364
|
@rc = MockRestClient.new
|
347
365
|
@domain = @rc.add_domain("mockdomain")
|
348
|
-
@domain.add_application("app1", "mock_type"
|
366
|
+
@domain.add_application("app1", "mock_type")
|
349
367
|
end
|
350
368
|
it { run_output.should match("app1 @ https://app1-mockdomain.fake.foo/") }
|
351
|
-
it { run_output.should match("Scaled x2") }
|
352
369
|
end
|
353
370
|
end
|
354
371
|
|
@@ -357,8 +374,7 @@ describe RHC::Commands::App do
|
|
357
374
|
|
358
375
|
context 'when run' do
|
359
376
|
before(:each) do
|
360
|
-
@
|
361
|
-
@domain = @rc.add_domain("mockdomain")
|
377
|
+
@domain = rest_client.add_domain("mockdomain")
|
362
378
|
@domain.add_application("app1", "mock_type")
|
363
379
|
end
|
364
380
|
it { run_output.should match("started") }
|
@@ -370,8 +386,7 @@ describe RHC::Commands::App do
|
|
370
386
|
|
371
387
|
context 'when run' do
|
372
388
|
before(:each) do
|
373
|
-
@
|
374
|
-
@domain = @rc.add_domain("mockdomain")
|
389
|
+
@domain = rest_client.add_domain("mockdomain")
|
375
390
|
@domain.add_application("app1", "mock_type")
|
376
391
|
end
|
377
392
|
it { run_output.should match("started") }
|
@@ -382,8 +397,7 @@ describe RHC::Commands::App do
|
|
382
397
|
describe 'app actions' do
|
383
398
|
|
384
399
|
before(:each) do
|
385
|
-
|
386
|
-
domain = @rc.add_domain("mockdomain")
|
400
|
+
domain = rest_client.add_domain("mockdomain")
|
387
401
|
app = domain.add_application("app1", "mock_type")
|
388
402
|
app.add_cartridge('mock_cart-1')
|
389
403
|
end
|
@@ -420,4 +434,13 @@ describe RHC::Commands::App do
|
|
420
434
|
it { run_output.should match('cleaned') }
|
421
435
|
end
|
422
436
|
end
|
437
|
+
|
438
|
+
describe "#create_app" do
|
439
|
+
it("should list cartridges when a server error happens") do
|
440
|
+
subject.should_receive(:list_cartridges)
|
441
|
+
domain = stub
|
442
|
+
domain.stub(:add_application).and_raise(RHC::Rest::ValidationException.new('Foo', :cartridges, 109))
|
443
|
+
expect{ subject.send(:create_app, 'name', 'jenkins-1.4', domain) }.to raise_error(RHC::Rest::ValidationException)
|
444
|
+
end
|
445
|
+
end
|
423
446
|
end
|