trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
module CF::App
|
5
|
+
class PushInteractionClass
|
6
|
+
include PushInteractions
|
7
|
+
def ask(question, options); end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe PushInteractionClass do
|
11
|
+
let(:domains) { [build(:domain), build(:domain)]}
|
12
|
+
let(:app){ build(:app, :space => build(:space, :domains => domains)) }
|
13
|
+
|
14
|
+
describe "#ask_domain" do
|
15
|
+
it "uses all space domains as choices with optional none" do
|
16
|
+
subject.should_receive(:ask).with("Domain", anything) do |_, options|
|
17
|
+
expect(options[:choices]).to eq(domains + ["none"])
|
18
|
+
end
|
19
|
+
|
20
|
+
subject.ask_domain(app)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has always a default value" do
|
24
|
+
subject.should_receive(:ask).with("Domain", anything) do |_, options|
|
25
|
+
expect(options[:default]).to eq domains.first
|
26
|
+
end
|
27
|
+
|
28
|
+
subject.ask_domain(app)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,332 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Push do
|
6
|
+
let(:global) { {:color => false, :quiet => true} }
|
7
|
+
let(:inputs) { {} }
|
8
|
+
let(:given) { {} }
|
9
|
+
let(:path) { "/somepath" }
|
10
|
+
let(:client) { build(:client) }
|
11
|
+
let(:push) { CF::App::Push.new(Mothership.commands[:push]) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
CF::CLI.any_instance.stub(:client) { client }
|
15
|
+
CF::CLI.any_instance.stub(:precondition) { nil }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "metadata" do
|
19
|
+
let(:command) { Mothership.commands[:push] }
|
20
|
+
|
21
|
+
describe "has the correct information" do
|
22
|
+
subject { command }
|
23
|
+
its(:description) { should eq "Push an application, syncing changes if it exists" }
|
24
|
+
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
25
|
+
end
|
26
|
+
|
27
|
+
it_behaves_like "inputs must have descriptions"
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#push" do
|
31
|
+
let(:app) { build(:app, :client => client, :name => "app-name-1") }
|
32
|
+
|
33
|
+
before do
|
34
|
+
app.stub(:upload)
|
35
|
+
app.changes = {}
|
36
|
+
push.stub(:warn)
|
37
|
+
client.stub(:app_by_name).and_return(app)
|
38
|
+
end
|
39
|
+
|
40
|
+
let(:inputs) { {} }
|
41
|
+
|
42
|
+
shared_examples_for "an input" do |*args|
|
43
|
+
context "when the new input is the same as the old" do
|
44
|
+
type, input = args
|
45
|
+
input ||= type
|
46
|
+
|
47
|
+
let(:inputs) { {input => old} }
|
48
|
+
|
49
|
+
it "does not update the app's #{type}" do
|
50
|
+
push.should_not_receive(:line)
|
51
|
+
app.should_not_receive(:update!)
|
52
|
+
expect do
|
53
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, {}, global)
|
54
|
+
push.push
|
55
|
+
end.not_to change { app.send(type) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "triggers the :push_app filter" do
|
61
|
+
push.should_receive(:filter).with(:push_app, app) { app }
|
62
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, {}, global)
|
63
|
+
push.push
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'uploading the app from the correct path' do
|
67
|
+
context 'when the user does not specify a path' do
|
68
|
+
it 'uploads the app' do
|
69
|
+
app.should_receive(:upload).with(File.expand_path('.'))
|
70
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, {}, {}, global)
|
71
|
+
push.push
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when the user specifies a path' do
|
76
|
+
it 'uploads the app' do
|
77
|
+
app.should_receive(:upload).with(path)
|
78
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, {:path => path}, {}, global)
|
79
|
+
push.push
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when the app is stopped" do
|
85
|
+
before do
|
86
|
+
app.stub(:started?).and_return(false)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "warns the user" do
|
90
|
+
push.should_receive(:warn).with("\n#{app.name} is currently stopped, start it with 'truck start'")
|
91
|
+
push.input = Mothership::Inputs.new(nil, push, {:path => path}, {}, global)
|
92
|
+
push.push
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "when no inputs other than path are given" do
|
97
|
+
let(:inputs) { {:path => ""} }
|
98
|
+
|
99
|
+
it "should not update the app" do
|
100
|
+
app.should_not_receive(:update!)
|
101
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
102
|
+
push.push
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should not set memory on the app" do
|
106
|
+
app.should_not_receive(:memory=)
|
107
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
108
|
+
push.push
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when memory is given" do
|
113
|
+
let(:old) { 1024 }
|
114
|
+
let(:new) { "2G" }
|
115
|
+
let(:app) { build(:app, :memory => old) }
|
116
|
+
let(:inputs) { {:path => path, :memory => new} }
|
117
|
+
|
118
|
+
it "updates the app memory, converting to megabytes" do
|
119
|
+
push.stub(:line)
|
120
|
+
app.should_receive(:update!)
|
121
|
+
expect { push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
122
|
+
push.push }.to change { app.memory }.from(old).to(2048)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "outputs the changed memory in human readable sizes" do
|
126
|
+
push.should_receive(:line).with("Changes:")
|
127
|
+
push.should_receive(:line).with("memory: 1G -> 2G")
|
128
|
+
app.stub(:update!)
|
129
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
130
|
+
push.push
|
131
|
+
end
|
132
|
+
|
133
|
+
it_behaves_like "an input", :memory
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when instances is given" do
|
137
|
+
let(:old) { 1 }
|
138
|
+
let(:new) { 2 }
|
139
|
+
let(:app) { build(:app, :total_instances => old) }
|
140
|
+
let(:inputs) { {:path => path, :instances => new} }
|
141
|
+
|
142
|
+
it "updates the app instances" do
|
143
|
+
push.stub(:line)
|
144
|
+
app.stub(:update!)
|
145
|
+
expect do
|
146
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
147
|
+
push.push
|
148
|
+
end.to change { app.total_instances }.from(old).to(new)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "outputs the changed instances" do
|
152
|
+
push.should_receive(:line).with("Changes:")
|
153
|
+
push.should_receive(:line).with("total_instances: 1 -> 2")
|
154
|
+
app.stub(:update!)
|
155
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
156
|
+
push.push
|
157
|
+
end
|
158
|
+
|
159
|
+
it_behaves_like "an input", :total_instances, :instances
|
160
|
+
end
|
161
|
+
|
162
|
+
context "when command is given" do
|
163
|
+
let(:old) { "./start" }
|
164
|
+
let(:new) { "./start foo " }
|
165
|
+
let(:app) { build(:app, :command => old) }
|
166
|
+
let(:inputs) { {:path => path, :command => new} }
|
167
|
+
|
168
|
+
it "updates the app command" do
|
169
|
+
push.stub(:line)
|
170
|
+
app.should_receive(:update!)
|
171
|
+
expect do
|
172
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
173
|
+
push.push
|
174
|
+
end.to change { app.command }.from("./start").to("./start foo ")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "outputs the changed command in single quotes" do
|
178
|
+
push.should_receive(:line).with("Changes:")
|
179
|
+
push.should_receive(:line).with("command: './start' -> './start foo '")
|
180
|
+
app.stub(:update!)
|
181
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
182
|
+
push.push
|
183
|
+
end
|
184
|
+
|
185
|
+
it_behaves_like "an input", :command
|
186
|
+
end
|
187
|
+
|
188
|
+
context "when restart is given" do
|
189
|
+
let(:inputs) { {:path => path, :restart => true, :memory => 4096} }
|
190
|
+
|
191
|
+
let(:mock_restart_command) do
|
192
|
+
MockRestartCommand.new
|
193
|
+
end
|
194
|
+
|
195
|
+
before do
|
196
|
+
CF::App::Base.any_instance.stub(:human_mb).and_return(0)
|
197
|
+
Restart.stub(:new).and_return(mock_restart_command)
|
198
|
+
end
|
199
|
+
|
200
|
+
context "when the app is already started" do
|
201
|
+
let(:app) { build(:app, :state => "STARTED") }
|
202
|
+
|
203
|
+
it "restarts the app after updating" do
|
204
|
+
push.stub(:line)
|
205
|
+
app.should_receive(:update!) do
|
206
|
+
expect(mock_restart_command.restarted_apps).to be_empty
|
207
|
+
end
|
208
|
+
|
209
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
210
|
+
push.push
|
211
|
+
|
212
|
+
expect(mock_restart_command.restarted_apps).to eq [app]
|
213
|
+
end
|
214
|
+
|
215
|
+
context "but there are no changes" do
|
216
|
+
let(:inputs) { {:path => path, :restart => true} }
|
217
|
+
|
218
|
+
it "restarts the app without updating" do
|
219
|
+
push.stub(:line)
|
220
|
+
app.should_not_receive(:update!)
|
221
|
+
|
222
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
223
|
+
push.push
|
224
|
+
|
225
|
+
mock_restart_command.restarted_apps.should == [app]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context "when the app is not already started" do
|
231
|
+
let(:app) { build(:app, :state => "STOPPED") }
|
232
|
+
|
233
|
+
it "updates the app without restarting" do
|
234
|
+
push.stub(:line)
|
235
|
+
app.should_receive(:update!)
|
236
|
+
|
237
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
238
|
+
push.push
|
239
|
+
|
240
|
+
expect(mock_restart_command.restarted_apps).to be_empty
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
context "when buildpack is given" do
|
246
|
+
let(:old) { nil }
|
247
|
+
let(:app) { build(:app, :buildpack => old) }
|
248
|
+
let(:inputs) { {:path => path, :buildpack => new} }
|
249
|
+
|
250
|
+
context "and it's an invalid URL" do
|
251
|
+
let(:new) { "git@github.com:foo/bar.git" }
|
252
|
+
|
253
|
+
before do
|
254
|
+
app.stub(:update!) do
|
255
|
+
raise CFoundry::MessageParseError.new(
|
256
|
+
"Request invalid due to parse error: Field: buildpack, Error: Value git@github.com:cloudfoundry/heroku-buildpack-ruby.git doesn't match regexp String /GIT_URL_REGEX/",
|
257
|
+
1001)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
it "fails and prints a pretty message" do
|
262
|
+
push.stub(:line)
|
263
|
+
expect do
|
264
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
265
|
+
push.push
|
266
|
+
end.to raise_error(
|
267
|
+
CF::UserError, "Buildpack must be a public git repository URI.")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context "and it's a valid URL" do
|
272
|
+
let(:new) { "git://github.com/foo/bar.git" }
|
273
|
+
|
274
|
+
it "updates the app's buildpack" do
|
275
|
+
push.stub(:line)
|
276
|
+
app.should_receive(:update!)
|
277
|
+
expect do
|
278
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
279
|
+
push.push
|
280
|
+
end.to change { app.buildpack }.from(old).to(new)
|
281
|
+
end
|
282
|
+
|
283
|
+
it "outputs the changed buildpack with single quotes" do
|
284
|
+
push.should_receive(:line).with("Changes:")
|
285
|
+
push.should_receive(:line).with("buildpack: '' -> '#{new}'")
|
286
|
+
app.stub(:update!)
|
287
|
+
push.input = Mothership::Inputs.new(nil, push, inputs, {}, global)
|
288
|
+
push.push
|
289
|
+
end
|
290
|
+
|
291
|
+
it_behaves_like "an input", :buildpack
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
describe "#setup_new_app (integration spec!!)" do
|
297
|
+
let(:app) { build(:app) }
|
298
|
+
let(:host) { "" }
|
299
|
+
let(:domain) { build(:domain) }
|
300
|
+
let(:inputs) do
|
301
|
+
{:name => "some-app",
|
302
|
+
:instances => 2,
|
303
|
+
:memory => 1024,
|
304
|
+
:host => host,
|
305
|
+
:domain => domain
|
306
|
+
}
|
307
|
+
end
|
308
|
+
let(:global) { {:quiet => true, :color => false, :force => true} }
|
309
|
+
|
310
|
+
before do
|
311
|
+
client.stub(:app) { app }
|
312
|
+
end
|
313
|
+
|
314
|
+
subject do
|
315
|
+
push.input = Mothership::Inputs.new(Mothership.commands[:push], push, inputs, global, global)
|
316
|
+
push.setup_new_app(path)
|
317
|
+
end
|
318
|
+
|
319
|
+
it "creates the app" do
|
320
|
+
app.should_receive(:create!)
|
321
|
+
app.should_receive(:upload).with(path)
|
322
|
+
|
323
|
+
push.should_receive(:filter).with(:create_app, app) { app }
|
324
|
+
push.should_receive(:filter).with(:push_app, app) { app }
|
325
|
+
push.should_receive(:invoke).with(:map, :app => app, :host => host, :domain => domain)
|
326
|
+
push.should_receive(:invoke).with(:start, :app => app)
|
327
|
+
subject
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CF::App::Rename do
|
4
|
+
let(:global) { { :color => false, :quiet => true } }
|
5
|
+
let(:inputs) { {} }
|
6
|
+
let(:given) { {} }
|
7
|
+
let(:client) { build(:client) }
|
8
|
+
let(:app) {}
|
9
|
+
let(:new_name) { "some-new-name" }
|
10
|
+
|
11
|
+
before do
|
12
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
13
|
+
CF::CLI.any_instance.stub(:precondition).and_return(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { Mothership.new.invoke(:rename, inputs, given, global) }
|
17
|
+
|
18
|
+
describe "metadata" do
|
19
|
+
let(:command) { Mothership.commands[:rename] }
|
20
|
+
|
21
|
+
describe "command" do
|
22
|
+
subject { command }
|
23
|
+
its(:description) { should eq "Rename an application" }
|
24
|
+
it { expect(Mothership::Help.group(:apps, :manage)).to include(subject) }
|
25
|
+
end
|
26
|
+
|
27
|
+
include_examples "inputs must have descriptions"
|
28
|
+
|
29
|
+
describe "arguments" do
|
30
|
+
subject { command.arguments }
|
31
|
+
it "has the correct argument order" do
|
32
|
+
should eq([
|
33
|
+
{ :type => :optional, :value => nil, :name => :app },
|
34
|
+
{ :type => :optional, :value => nil, :name => :name }
|
35
|
+
])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when there are no apps" do
|
41
|
+
before do
|
42
|
+
client.stub(:apps).and_return([])
|
43
|
+
end
|
44
|
+
|
45
|
+
context "and an app is given" do
|
46
|
+
let(:given) { { :app => "some-app" } }
|
47
|
+
it { expect { subject }.to raise_error(CF::UserError, "Unknown app 'some-app'.") }
|
48
|
+
end
|
49
|
+
|
50
|
+
context "and an app is not given" do
|
51
|
+
it { expect { subject }.to raise_error(CF::UserError, "No applications.") }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when there are apps" do
|
56
|
+
let(:apps) { [build(:app, :client => client), build(:app, :client => client)] }
|
57
|
+
let(:renamed_app) { apps.first }
|
58
|
+
|
59
|
+
before do
|
60
|
+
client.stub(:apps).and_return(apps)
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when the defaults are used" do
|
64
|
+
it "asks for the app and new name and renames" do
|
65
|
+
should_ask("Rename which application?", anything) { renamed_app }
|
66
|
+
should_ask("New name") { new_name }
|
67
|
+
renamed_app.should_receive(:name=).with(new_name)
|
68
|
+
renamed_app.should_receive(:update!)
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when no name is provided, but a app is" do
|
74
|
+
let(:given) { { :app => renamed_app.name } }
|
75
|
+
|
76
|
+
it "asks for the new name and renames" do
|
77
|
+
dont_allow_ask("Rename which application?", anything)
|
78
|
+
should_ask("New name") { new_name }
|
79
|
+
renamed_app.should_receive(:name=).with(new_name)
|
80
|
+
renamed_app.should_receive(:update!)
|
81
|
+
subject
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when an app is provided and a name" do
|
86
|
+
let(:inputs) { { :app => renamed_app, :name => new_name } }
|
87
|
+
|
88
|
+
it "renames the app" do
|
89
|
+
renamed_app.should_receive(:update!)
|
90
|
+
subject
|
91
|
+
end
|
92
|
+
|
93
|
+
it "displays the progress" do
|
94
|
+
mock_with_progress("Renaming to #{new_name}")
|
95
|
+
renamed_app.should_receive(:update!)
|
96
|
+
|
97
|
+
subject
|
98
|
+
end
|
99
|
+
|
100
|
+
context "and the name already exists" do
|
101
|
+
it "fails" do
|
102
|
+
renamed_app.should_receive(:update!) { raise CFoundry::AppNameTaken.new("Bad Name", 404) }
|
103
|
+
expect { subject }.to raise_error(CFoundry::AppNameTaken)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|