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,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CFMicro::McfCommand do
|
4
|
+
shared_examples 'micro common inputs' do
|
5
|
+
describe 'inputs' do
|
6
|
+
subject { command.inputs }
|
7
|
+
it { expect(subject[:vmx][:description]).to eq "Path to micro.vmx" }
|
8
|
+
it { expect(subject[:password][:description]).to eq "Cleartext password for guest VM vcap user" }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'arguments' do
|
12
|
+
subject { command.arguments }
|
13
|
+
|
14
|
+
it 'has the correct argument order' do
|
15
|
+
should eq([
|
16
|
+
{:type => :required, :value => nil, :name => :vmx},
|
17
|
+
{:type => :optional, :value => nil, :name => :password}
|
18
|
+
])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'micro_status' do
|
24
|
+
describe '#metadata' do
|
25
|
+
let(:command) { Mothership.commands[:micro_status] }
|
26
|
+
|
27
|
+
include_examples 'micro common inputs'
|
28
|
+
|
29
|
+
describe 'command' do
|
30
|
+
subject { command }
|
31
|
+
|
32
|
+
its(:description) { should eq "Display Micro Cloud Foundry VM status" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#micro_offline' do
|
38
|
+
describe 'metadata' do
|
39
|
+
let(:command) { Mothership.commands[:micro_offline] }
|
40
|
+
|
41
|
+
include_examples 'micro common inputs'
|
42
|
+
|
43
|
+
describe 'command' do
|
44
|
+
subject { command }
|
45
|
+
|
46
|
+
its(:description) { should eq "Micro Cloud Foundry offline mode" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#micro_online' do
|
52
|
+
describe 'metadata' do
|
53
|
+
let(:command) { Mothership.commands[:micro_online] }
|
54
|
+
|
55
|
+
include_examples 'micro common inputs'
|
56
|
+
|
57
|
+
describe 'command' do
|
58
|
+
subject { command }
|
59
|
+
|
60
|
+
its(:description) { should eq "Micro Cloud Foundry online mode" }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
SPEC_ROOT = File.dirname(__FILE__).freeze
|
2
|
+
|
3
|
+
require "rspec"
|
4
|
+
require "cfoundry"
|
5
|
+
require "cfoundry/test_support"
|
6
|
+
require "cf"
|
7
|
+
require "cf/test_support"
|
8
|
+
require "webmock"
|
9
|
+
require "webmock/rspec"
|
10
|
+
require "ostruct"
|
11
|
+
require "fakefs/safe"
|
12
|
+
require "blue-shell"
|
13
|
+
|
14
|
+
Dir.glob("support/mock_commands/*").each { |f| require f }
|
15
|
+
|
16
|
+
TRAVIS_BUILD_ID = ENV["TRAVIS_BUILD_ID"]
|
17
|
+
|
18
|
+
OriginalFile = File
|
19
|
+
|
20
|
+
class FakeFS::File
|
21
|
+
def self.fnmatch(*args, &blk)
|
22
|
+
OriginalFile.fnmatch(*args, &blk)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def cf_bin
|
27
|
+
File.expand_path("#{SPEC_ROOT}/../bin/truck.dev")
|
28
|
+
end
|
29
|
+
|
30
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
|
31
|
+
require file
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec.configure do |c|
|
35
|
+
c.include BlueShell::Matchers
|
36
|
+
|
37
|
+
if RUBY_VERSION =~ /^1\.8\.\d/
|
38
|
+
c.filter_run_excluding :ruby19 => true
|
39
|
+
end
|
40
|
+
|
41
|
+
c.include FakeHomeDir
|
42
|
+
c.include CliHelper
|
43
|
+
c.include InteractHelper
|
44
|
+
c.include ConfigHelper
|
45
|
+
c.include FeaturesHelper
|
46
|
+
|
47
|
+
c.before(:all) do
|
48
|
+
WebMock.disable_net_connect!(:allow_localhost => true)
|
49
|
+
end
|
50
|
+
|
51
|
+
c.before do
|
52
|
+
CF::CLI.send(:class_variable_set, :@@client, nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
c.after do
|
56
|
+
if example.exception != nil && example.exception.message.include?("~/.truck/crash")
|
57
|
+
puts '~/.truck/crash output for failed spec:'
|
58
|
+
puts `cat ~/.truck/crash`
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def name_list(xs)
|
64
|
+
if xs.empty?
|
65
|
+
"none"
|
66
|
+
else
|
67
|
+
xs.collect(&:name).join(", ")
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module CliHelper
|
2
|
+
def stub_client_and_precondition
|
3
|
+
stub_client
|
4
|
+
stub_precondition
|
5
|
+
end
|
6
|
+
|
7
|
+
def stub_client
|
8
|
+
described_class.any_instance.stub(:client).and_return(client)
|
9
|
+
end
|
10
|
+
|
11
|
+
def stub_precondition
|
12
|
+
described_class.any_instance.stub(:precondition)
|
13
|
+
end
|
14
|
+
|
15
|
+
def wrap_errors
|
16
|
+
yield
|
17
|
+
rescue CF::UserError => e
|
18
|
+
err e.message
|
19
|
+
end
|
20
|
+
|
21
|
+
def cf(argv)
|
22
|
+
Mothership.new.exit_status 0
|
23
|
+
CF::CLI.stub(:exit) { |code| code }
|
24
|
+
capture_output { CF::CLI.start(argv + ["--debug", "--no-script"]) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def bool_flag(flag)
|
28
|
+
"#{'no-' unless send(flag)}#{flag.to_s.gsub('_', '-')}"
|
29
|
+
end
|
30
|
+
|
31
|
+
attr_reader :stdout, :stderr, :stdin, :status
|
32
|
+
|
33
|
+
def capture_output
|
34
|
+
$real_stdout = $stdout
|
35
|
+
$real_stderr = $stderr
|
36
|
+
$real_stdin = $stdin
|
37
|
+
$stdout = @stdout = StringIO.new
|
38
|
+
$stderr = @stderr = StringIO.new
|
39
|
+
$stdin = @stdin = StringIO.new
|
40
|
+
@status = yield
|
41
|
+
@stdout.rewind
|
42
|
+
@stderr.rewind
|
43
|
+
@status
|
44
|
+
ensure
|
45
|
+
$stdout = $real_stdout
|
46
|
+
$stderr = $real_stderr
|
47
|
+
$stdin = $real_stdin
|
48
|
+
end
|
49
|
+
|
50
|
+
def capture_exceptional_output
|
51
|
+
$real_stdout = $stdout
|
52
|
+
$real_stderr = $stderr
|
53
|
+
$real_stdin = $stdin
|
54
|
+
$stdout = @stdout = StringIO.new
|
55
|
+
$stderr = @stderr = StringIO.new
|
56
|
+
$stdin = @stdin = StringIO.new
|
57
|
+
begin
|
58
|
+
@status = yield
|
59
|
+
rescue => e
|
60
|
+
@stderr.write(e.message)
|
61
|
+
end
|
62
|
+
@stdout.rewind
|
63
|
+
@stderr.rewind
|
64
|
+
@status
|
65
|
+
ensure
|
66
|
+
$stdout = $real_stdout
|
67
|
+
$stderr = $real_stderr
|
68
|
+
$stdin = $real_stdin
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def output
|
73
|
+
@output ||= BlueShell::BufferedReaderExpector.new(stdout)
|
74
|
+
end
|
75
|
+
|
76
|
+
def error_output
|
77
|
+
@error_output ||= BlueShell::BufferedReaderExpector.new(stderr)
|
78
|
+
end
|
79
|
+
|
80
|
+
def mock_invoke(*args)
|
81
|
+
described_class.any_instance.should_receive(:invoke).with(*args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def dont_allow_invoke(*args)
|
85
|
+
described_class.any_instance.should_not_receive(:invoke).with(*args)
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ConfigHelper
|
2
|
+
def write_token_file(config={})
|
3
|
+
File.open(File.expand_path(tokens_file_path), 'w') do |f|
|
4
|
+
f.puts YAML.dump(
|
5
|
+
{ "https://api.some-domain.com" =>
|
6
|
+
{
|
7
|
+
:version => 2,
|
8
|
+
:token => 'bearer token',
|
9
|
+
:refresh_token => nil
|
10
|
+
}.merge(config)
|
11
|
+
}
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "fakefs/safe"
|
2
|
+
|
3
|
+
module FakeHomeDir
|
4
|
+
def self.included(klass)
|
5
|
+
super
|
6
|
+
klass.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def stub_home_dir_with(&block)
|
11
|
+
around do |example|
|
12
|
+
bootstrap_dir = instance_exec(&block)
|
13
|
+
|
14
|
+
if bootstrap_dir
|
15
|
+
fixture = File.expand_path(bootstrap_dir)
|
16
|
+
files = build_file_buffer(fixture)
|
17
|
+
end
|
18
|
+
|
19
|
+
FakeFS do
|
20
|
+
home = File.expand_path("~")
|
21
|
+
write_file_buffer(files, home) if files
|
22
|
+
example.call
|
23
|
+
end
|
24
|
+
|
25
|
+
FakeFS::FileSystem.clear
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def build_file_buffer(path)
|
33
|
+
files = {}
|
34
|
+
|
35
|
+
Dir.glob("#{path}/**/*", File::FNM_DOTMATCH).each do |file|
|
36
|
+
next if file =~ /\.$/
|
37
|
+
next if File.directory?(file)
|
38
|
+
|
39
|
+
files[file.sub(path + "/", "")] = File.read(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
files
|
43
|
+
end
|
44
|
+
|
45
|
+
def write_file_buffer(files, path)
|
46
|
+
files.each do |file, body|
|
47
|
+
full = "#{path}/#{file}"
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(File.dirname(full))
|
50
|
+
File.open(full, "w") do |io|
|
51
|
+
io.write body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module FeaturesHelper
|
2
|
+
def login
|
3
|
+
set_target
|
4
|
+
logout
|
5
|
+
|
6
|
+
username = ENV['CF_V2_TEST_USER']
|
7
|
+
password = ENV['CF_V2_TEST_PASSWORD']
|
8
|
+
organization = ENV['CF_V2_TEST_ORGANIZATION']
|
9
|
+
space = ENV['CF_V2_TEST_SPACE']
|
10
|
+
|
11
|
+
cmd = "#{cf_bin} login #{username} --password #{password} -o #{organization}"
|
12
|
+
cmd += " -s #{space}"
|
13
|
+
BlueShell::Runner.run(cmd) do |runner|
|
14
|
+
runner.wait_for_exit 60
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def logout
|
19
|
+
BlueShell::Runner.run("#{cf_bin} logout") do |runner|
|
20
|
+
runner.wait_for_exit 60
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_target
|
25
|
+
target = ENV['CF_V2_TEST_TARGET']
|
26
|
+
BlueShell::Runner.run("#{cf_bin} target #{target}") do |runner|
|
27
|
+
runner.wait_for_exit 20
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_service_instance(service_name, instance_name, opts = {})
|
32
|
+
plan_name = opts[:plan]
|
33
|
+
credentials = opts[:credentials]
|
34
|
+
|
35
|
+
BlueShell::Runner.run("#{cf_bin} create-service") do |runner|
|
36
|
+
expect(runner).to say "What kind?>"
|
37
|
+
runner.send_keys service_name
|
38
|
+
|
39
|
+
expect(runner).to say "Name?>"
|
40
|
+
runner.send_keys instance_name
|
41
|
+
|
42
|
+
if service_name == "user-provided"
|
43
|
+
expect(runner).to say "What credential parameters should applications use to connect to this service instance?\n(e.g. hostname, port, password)>"
|
44
|
+
runner.send_keys credentials.keys.join(", ")
|
45
|
+
|
46
|
+
credentials.each do |key, value|
|
47
|
+
expect(runner).to say key.to_s
|
48
|
+
runner.send_keys value.to_s
|
49
|
+
end
|
50
|
+
else
|
51
|
+
expect(runner).to say "Which plan?"
|
52
|
+
runner.send_keys plan_name
|
53
|
+
end
|
54
|
+
|
55
|
+
expect(runner).to say "Creating service #{instance_name}... OK"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def push_app(app_folder, deployed_app_name, opts = {})
|
60
|
+
push_cmd = "#{cf_bin} push --no-manifest"
|
61
|
+
push_cmd += " --command #{opts[:start_command]}" if opts[:start_command]
|
62
|
+
|
63
|
+
Dir.chdir("#{SPEC_ROOT}/assets/#{app_folder}") do
|
64
|
+
BlueShell::Runner.run(push_cmd) do |runner|
|
65
|
+
expect(runner).to say "Name>"
|
66
|
+
runner.send_keys deployed_app_name
|
67
|
+
|
68
|
+
expect(runner).to say "Instances> 1", 15
|
69
|
+
runner.send_return
|
70
|
+
|
71
|
+
expect(runner).to say "Memory Limit>"
|
72
|
+
runner.send_keys "128M"
|
73
|
+
|
74
|
+
expect(runner).to say "Creating #{deployed_app_name}... OK"
|
75
|
+
|
76
|
+
expect(runner).to say "Subdomain> #{deployed_app_name}"
|
77
|
+
runner.send_return
|
78
|
+
|
79
|
+
expect(runner).to say "1:"
|
80
|
+
expect(runner).to say "Domain>"
|
81
|
+
runner.send_keys "1"
|
82
|
+
|
83
|
+
expect(runner).to say /Creating route #{deployed_app_name}\..*\.\.\. OK/
|
84
|
+
expect(runner).to say /Binding #{deployed_app_name}\..* to #{deployed_app_name}\.\.\. OK/
|
85
|
+
|
86
|
+
expect(runner).to say "Create services for application?> n"
|
87
|
+
runner.send_return
|
88
|
+
|
89
|
+
if runner.expect "Bind other services to application?> n", 15
|
90
|
+
runner.send_return
|
91
|
+
end
|
92
|
+
|
93
|
+
expect(runner).to say "Push successful!"
|
94
|
+
|
95
|
+
runner.wait_for_exit opts[:timeout] || 30
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module InteractHelper
|
2
|
+
def stub_ask(*args, &block)
|
3
|
+
CF::CLI.any_instance.stub(:ask).with(*args, &block)
|
4
|
+
end
|
5
|
+
|
6
|
+
def should_ask(*args, &block)
|
7
|
+
CF::CLI.any_instance.should_receive(:ask).with(*args, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def should_print(*args, &block)
|
11
|
+
CF::CLI.any_instance.should_receive(:line).with(*args, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def should_print_error(*args, &block)
|
15
|
+
CF::CLI.any_instance.should_receive(:err).with(*args, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def dont_allow_ask(*args)
|
19
|
+
CF::CLI.any_instance.should_not_receive(:ask).with(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def mock_with_progress(message)
|
23
|
+
CF::CLI.any_instance.should_receive(:with_progress).with(message) do |_, &block|
|
24
|
+
block.call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class HasLabelMatcher
|
2
|
+
def initialize(expected_label)
|
3
|
+
@expected = expected_label
|
4
|
+
end
|
5
|
+
def failure_message_for_should
|
6
|
+
"#{actual} does not have label #{@expected}"
|
7
|
+
end
|
8
|
+
def ==(actual)
|
9
|
+
actual.label == @expected
|
10
|
+
end
|
11
|
+
alias_method :matches?, :==
|
12
|
+
end
|
13
|
+
|
14
|
+
def has_label(expected_label)
|
15
|
+
HasLabelMatcher.new(expected_label)
|
16
|
+
end
|