cf_script 0.0.1.beta.1 → 0.0.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +18 -0
- data/README.md +182 -34
- data/Rakefile +0 -13
- data/lib/cf_script/command/base.rb +1 -1
- data/lib/cf_script/command/cf/apps/app.rb +1 -1
- data/lib/cf_script/command/cf/apps/apps.rb +5 -3
- data/lib/cf_script/command/cf/apps/delete.rb +25 -0
- data/lib/cf_script/command/cf/apps/env.rb +4 -2
- data/lib/cf_script/command/cf/apps/push.rb +7 -2
- data/lib/cf_script/command/cf/apps/rename.rb +20 -0
- data/lib/cf_script/command/cf/apps/restage.rb +1 -1
- data/lib/cf_script/command/cf/apps/restart.rb +1 -1
- data/lib/cf_script/command/cf/apps/set_env.rb +1 -1
- data/lib/cf_script/command/cf/apps/start.rb +1 -1
- data/lib/cf_script/command/cf/apps/stop.rb +3 -2
- data/lib/cf_script/command/cf/apps/unset_env.rb +1 -1
- data/lib/cf_script/command/cf/apps.rb +5 -1
- data/lib/cf_script/command/cf/general/api.rb +1 -1
- data/lib/cf_script/command/cf/general/auth.rb +1 -1
- data/lib/cf_script/command/cf/general/login.rb +1 -1
- data/lib/cf_script/command/cf/general/logout.rb +1 -1
- data/lib/cf_script/command/cf/general/target.rb +1 -1
- data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/create_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/delete_route.rb +5 -2
- data/lib/cf_script/command/cf/routes/map_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/routes.rb +1 -1
- data/lib/cf_script/command/cf/routes/unmap_route.rb +1 -1
- data/lib/cf_script/command/cf/spaces/space.rb +1 -1
- data/lib/cf_script/command/cf/spaces/spaces.rb +1 -1
- data/lib/cf_script/command/runner.rb +1 -15
- data/lib/cf_script/config.rb +3 -1
- data/lib/cf_script/executor/recorder.rb +3 -1
- data/lib/cf_script/executor/simple.rb +22 -9
- data/lib/cf_script/executor.rb +0 -1
- data/lib/cf_script/object/api_endpoint.rb +1 -1
- data/lib/cf_script/object/app_info.rb +1 -1
- data/lib/cf_script/object/app_list.rb +21 -5
- data/lib/cf_script/object/attribute.rb +1 -1
- data/lib/cf_script/object/attribute_list.rb +1 -1
- data/lib/cf_script/object/instance_status.rb +1 -1
- data/lib/cf_script/object/route_info.rb +1 -1
- data/lib/cf_script/object/space.rb +1 -1
- data/lib/cf_script/object/target.rb +1 -1
- data/lib/cf_script/object.rb +0 -11
- data/lib/cf_script/output/buffer.rb +1 -1
- data/lib/cf_script/scope/app/routes.rb +1 -1
- data/lib/cf_script/scope/app.rb +0 -26
- data/lib/cf_script/scope/target.rb +7 -1
- data/lib/cf_script/ui.rb +2 -6
- data/lib/cf_script/version.rb +1 -1
- data/lib/cf_script.rb +0 -2
- data/test/fixtures/commands/apps/delete/good.yml +8 -0
- data/test/fixtures/commands/apps/delete/not_exist.yml +9 -0
- data/test/fixtures/commands/apps/env/{empty.yml → empty_vars.yml} +0 -0
- data/test/fixtures/commands/apps/rename/good.yml +8 -0
- data/test/fixtures/commands/apps/rename/not_found.yml +8 -0
- data/test/fixtures/commands/{apps/set_env → common}/empty.yml +0 -0
- data/test/lib/cf_script/command/cf/apps/app_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/apps_test.rb +12 -3
- data/test/lib/cf_script/command/cf/apps/delete_test.rb +51 -0
- data/test/lib/cf_script/command/cf/apps/env_test.rb +12 -2
- data/test/lib/cf_script/command/cf/apps/push_test.rb +14 -0
- data/test/lib/cf_script/command/cf/apps/rename_test.rb +35 -0
- data/test/lib/cf_script/command/cf/apps/restage_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/restart_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/start_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
- data/test/lib/cf_script/command/cf/general/login_test.rb +9 -10
- data/test/lib/cf_script/command/cf/routes/create_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/delete_route_test.rb +18 -0
- data/test/lib/cf_script/command/cf/routes/map_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/routes_test.rb +8 -0
- data/test/lib/cf_script/command/cf/routes/unmap_route_test.rb +12 -0
- data/test/lib/cf_script/object/app_info_test.rb +4 -4
- data/test/lib/cf_script/object/app_list_test.rb +68 -2
- data/test/lib/cf_script/output/buffer_test.rb +9 -9
- data/test/lib/cf_script/output/parser/section_test.rb +4 -2
- data/test/lib/cf_script/output/tests_test.rb +24 -24
- data/test/lib/cf_script/output_test.rb +23 -18
- data/test/lib/cf_script/scope/app/env_test.rb +58 -0
- data/test/lib/cf_script/scope/app/routes_test.rb +56 -0
- data/test/lib/cf_script/scope/app/state_test.rb +30 -0
- data/test/lib/cf_script/scope/script_test.rb +3 -2
- data/test/lib/cf_script/scope/target_test.rb +38 -23
- data/test/lib/cf_script/scope_test.rb +10 -6
- data/test/lib/cf_script/ui_test.rb +133 -0
- data/test/lib/cf_script_test.rb +14 -8
- data/test/support/assertions.rb +25 -0
- data/test/support/helpers/fixture_executor.rb +1 -1
- data/test/support/helpers/mock_execution.rb +29 -7
- metadata +23 -14
- data/lib/cf_script/callbacks.rb +0 -43
- data/lib/cf_script/executor/non_blocking.rb +0 -107
- data/lib/cf_script/object/app_spec.rb +0 -55
- data/test/fixtures/commands/apps/unset_env/empty.yml +0 -5
- data/test/fixtures/commands/general/auth/empty.yml +0 -5
- data/test/fixtures/commands/general/target/empty.yml +0 -5
- data/test/fixtures/commands/spaces/space/empty.yml +0 -5
- data/test/fixtures/commands/spaces/spaces/empty.yml +0 -5
@@ -71,27 +71,13 @@ module CfScript::Command
|
|
71
71
|
def run_command(command, *args, &block)
|
72
72
|
command_line = command.line(cf_env, cf_bin, args)
|
73
73
|
|
74
|
-
trace(:running, command_line.hide_sensitive
|
74
|
+
trace(:running, command_line.hide_sensitive)
|
75
75
|
|
76
76
|
stdout, stderr, status = cf_executor.execute(cf_env, command_line)
|
77
77
|
|
78
78
|
output = CfScript::Output.new(command_line, stdout, stderr, status)
|
79
79
|
|
80
|
-
unless output.good?
|
81
|
-
run_error!(command_line, output)
|
82
|
-
end
|
83
|
-
|
84
80
|
block_given? ? yield(output) : output
|
85
81
|
end
|
86
|
-
|
87
|
-
def run_error!(command_line, output)
|
88
|
-
unless CfScript.stdout.is_a?(StringIO)
|
89
|
-
CfScript.stdout.puts output.stdout unless output.stdout.empty?
|
90
|
-
end
|
91
|
-
|
92
|
-
unless CfScript.stderr.is_a?(StringIO)
|
93
|
-
CfScript.stderr.puts output.stderr unless output.stderr.empty?
|
94
|
-
end
|
95
|
-
end
|
96
82
|
end
|
97
83
|
end
|
data/lib/cf_script/config.rb
CHANGED
@@ -45,12 +45,14 @@ class CfScript::Config
|
|
45
45
|
attr_accessor :color
|
46
46
|
|
47
47
|
attr_accessor :executor
|
48
|
+
attr_accessor :echo_output
|
48
49
|
|
49
50
|
def initialize
|
50
51
|
@trace = ENV['TRACE'] || false
|
51
52
|
@color = true
|
52
53
|
|
53
|
-
@executor =
|
54
|
+
@executor = default_executor
|
55
|
+
@echo_output = true
|
54
56
|
end
|
55
57
|
|
56
58
|
def default_executor
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class CfScript::Executor::Recorder
|
2
|
+
attr_reader :executions
|
3
|
+
|
2
4
|
def initialize(executor = nil)
|
3
5
|
@executions = []
|
4
|
-
@executor = executor || CfScript
|
6
|
+
@executor = executor || CfScript.config.runtime.executor
|
5
7
|
end
|
6
8
|
|
7
9
|
def execute(env, command_line)
|
@@ -1,17 +1,30 @@
|
|
1
|
-
require '
|
1
|
+
require 'pty'
|
2
|
+
require 'io/console'
|
2
3
|
|
3
4
|
class CfScript::Executor::Simple
|
4
|
-
def initialize
|
5
|
-
@executions = 0
|
6
|
-
end
|
7
|
-
|
8
5
|
def execute(env, command_line)
|
9
|
-
|
6
|
+
out = ''
|
10
7
|
|
11
|
-
|
8
|
+
PTY.spawn(command_line.to_s)do |i, o, pid|
|
9
|
+
begin
|
10
|
+
i.sync
|
11
|
+
i.raw!
|
12
12
|
|
13
|
-
|
13
|
+
i.each_line do |line|
|
14
|
+
echo(line)
|
15
|
+
out << line
|
16
|
+
end
|
17
|
+
rescue Errno::EIO => e
|
18
|
+
# Ignored
|
19
|
+
ensure
|
20
|
+
::Process.wait pid
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
[out, '', $?]
|
25
|
+
end
|
14
26
|
|
15
|
-
|
27
|
+
def echo(line)
|
28
|
+
STDOUT.print line if CfScript.config.runtime.echo_output
|
16
29
|
end
|
17
30
|
end
|
data/lib/cf_script/executor.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class CfScript::AppList
|
1
|
+
class CfScript::AppList
|
2
2
|
extend Forwardable
|
3
3
|
include Enumerable
|
4
4
|
|
@@ -8,17 +8,33 @@ class CfScript::AppList < CfScript::Object
|
|
8
8
|
|
9
9
|
def_delegators :@list, :<<, :[], :clear, :length, :each, :select
|
10
10
|
|
11
|
+
def names
|
12
|
+
@list.map(&:name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def ==(other)
|
16
|
+
names == other.names
|
17
|
+
end
|
18
|
+
|
19
|
+
def each_name(&block)
|
20
|
+
names.each { |name| yield(name) }
|
21
|
+
end
|
22
|
+
|
11
23
|
def select!(options)
|
12
|
-
if options[:
|
13
|
-
@list.
|
24
|
+
if options[:matching]
|
25
|
+
@list.select! { |app_info| app_info.name =~ /#{options[:matching]}/ }
|
14
26
|
end
|
15
27
|
|
16
|
-
if options[:
|
17
|
-
@list.reject! { |app_info| app_info.
|
28
|
+
if options[:starting_with]
|
29
|
+
@list.reject! { |app_info| app_info.name !~ /\A#{options[:starting_with]}/ }
|
18
30
|
end
|
19
31
|
|
20
32
|
if options[:ending_with]
|
21
33
|
@list.reject! { |app_info| app_info.name !~ /#{options[:ending_with]}\z/ }
|
22
34
|
end
|
35
|
+
|
36
|
+
if options[:state]
|
37
|
+
@list.reject! { |app_info| app_info.requested_state !~ /\A#{options[:state]}\z/ }
|
38
|
+
end
|
23
39
|
end
|
24
40
|
end
|
data/lib/cf_script/object.rb
CHANGED
@@ -1,21 +1,10 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'forwardable'
|
3
3
|
|
4
|
-
class CfScript::Object
|
5
|
-
class << self
|
6
|
-
attr_reader :_cf_script_object_count
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@@_cf_script_object_count += 1
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
4
|
require 'cf_script/object/attribute'
|
15
5
|
require 'cf_script/object/attribute_list'
|
16
6
|
|
17
7
|
require 'cf_script/object/api_endpoint'
|
18
|
-
require 'cf_script/object/app_spec'
|
19
8
|
require 'cf_script/object/app_info'
|
20
9
|
require 'cf_script/object/app_list'
|
21
10
|
require 'cf_script/object/instance_status'
|
data/lib/cf_script/scope/app.rb
CHANGED
@@ -6,10 +6,8 @@ module CfScript::Scope
|
|
6
6
|
|
7
7
|
attr_reader :name
|
8
8
|
attr_reader :app_info
|
9
|
-
#attr_reader :app_spec
|
10
9
|
attr_reader :current_target
|
11
10
|
|
12
|
-
#include CfScript::Callbacks
|
13
11
|
include CfScript::UI
|
14
12
|
include CfScript::UI::NameTag
|
15
13
|
|
@@ -20,11 +18,9 @@ module CfScript::Scope
|
|
20
18
|
when String, Symbol
|
21
19
|
@name = name_or_info
|
22
20
|
@app_info = nil
|
23
|
-
#@app_spec = spec_for(name)
|
24
21
|
when CfScript::AppInfo
|
25
22
|
@name = name_or_info.name
|
26
23
|
@app_info = name_or_info
|
27
|
-
#@app_spec = spec_for(name)
|
28
24
|
else
|
29
25
|
raise "App accepts a name (String or Symbol) or an AppInfo object, " +
|
30
26
|
"but a #{name_or_info.class.name} was given"
|
@@ -49,28 +45,6 @@ module CfScript::Scope
|
|
49
45
|
"#{current_target.space}:#{name}"
|
50
46
|
end
|
51
47
|
|
52
|
-
#def run_callbacks(stage, command)
|
53
|
-
# return unless app_spec
|
54
|
-
|
55
|
-
# app_spec.callbacks_for(stage, command).each do |callback|
|
56
|
-
# self.instance_eval(&callback)
|
57
|
-
# end
|
58
|
-
#end
|
59
|
-
|
60
|
-
#def callbacks_before(command)
|
61
|
-
# run_callbacks(:before, command)
|
62
|
-
#end
|
63
|
-
|
64
|
-
#def callbacks_after(command)
|
65
|
-
# run_callbacks(:after, command)
|
66
|
-
#end
|
67
|
-
|
68
|
-
#def callbacks_around(command, &block)
|
69
|
-
# run_callbacks(:before, command)
|
70
|
-
# self.instance_eval(&block)
|
71
|
-
# run_callbacks(:after, command)
|
72
|
-
#end
|
73
|
-
|
74
48
|
private
|
75
49
|
|
76
50
|
def cf_self
|
data/lib/cf_script/ui.rb
CHANGED
@@ -43,7 +43,7 @@ module CfScript::UI
|
|
43
43
|
|
44
44
|
default: "\xE2\x9E\x96",
|
45
45
|
|
46
|
-
|
46
|
+
lobster_bisque: "🍲", # h/t @dbelloti
|
47
47
|
}
|
48
48
|
|
49
49
|
module_function
|
@@ -72,10 +72,6 @@ module CfScript::UI
|
|
72
72
|
COLORS[CfScript.config.ui.color ? type : :default]
|
73
73
|
end
|
74
74
|
|
75
|
-
def ui_style(text, type = :default)
|
76
|
-
text.colorize with_color_of(type)
|
77
|
-
end
|
78
|
-
|
79
75
|
def emoji(type)
|
80
76
|
"#{(EMOJI.key?(type) ? EMOJI[type] : EMOJI[:default])} "
|
81
77
|
end
|
@@ -105,7 +101,7 @@ module CfScript::UI
|
|
105
101
|
end
|
106
102
|
|
107
103
|
def tag_format(tag, type = :default)
|
108
|
-
if tag
|
104
|
+
if tag && CfScript.config.ui.tags
|
109
105
|
list = []
|
110
106
|
|
111
107
|
list << tag_open(type)
|
data/lib/cf_script/version.rb
CHANGED
data/lib/cf_script.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require_relative './cf_script/version'
|
2
2
|
require_relative './cf_script/config'
|
3
|
-
require_relative './cf_script/callbacks'
|
4
3
|
require_relative './cf_script/utils'
|
5
4
|
require_relative './cf_script/ui'
|
6
5
|
require_relative './cf_script/output'
|
@@ -20,7 +19,6 @@ module CfScript
|
|
20
19
|
attr_accessor :cf_call_stack
|
21
20
|
end
|
22
21
|
|
23
|
-
#extend CfScript::Context
|
24
22
|
extend CfScript::Scope::Execution
|
25
23
|
extend CfScript::UI
|
26
24
|
|
File without changes
|
File without changes
|
@@ -33,6 +33,14 @@ describe 'AppCommand' do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
it "returns nil if no attributes were found" do
|
37
|
+
fake_cf app: :empty do
|
38
|
+
result = command.run(:worker)
|
39
|
+
|
40
|
+
assert_equal nil, result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
36
44
|
it "returns nil when the app is not found" do
|
37
45
|
fake_cf app: :not_found do
|
38
46
|
assert_equal nil, command.run(:api)
|
@@ -8,7 +8,7 @@ describe 'AppsCommand' do
|
|
8
8
|
it_behaves_like 'a command object that', {
|
9
9
|
has_type: :apps,
|
10
10
|
has_name: :apps,
|
11
|
-
fails_with:
|
11
|
+
fails_with: CfScript::AppList.new # an empty AppList
|
12
12
|
}
|
13
13
|
|
14
14
|
it "returns an AppList object" do
|
@@ -70,12 +70,21 @@ describe 'AppsCommand' do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
it "returns an empty AppList for empty output" do
|
74
|
+
fake_cf apps: :empty do
|
75
|
+
apps = command.run
|
76
|
+
|
77
|
+
assert_instance_of CfScript::AppList, apps
|
78
|
+
assert_equal CfScript::AppList.new, apps
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
73
82
|
it "returns an empty Array when no apps are found" do
|
74
83
|
fake_cf apps: :no_apps do
|
75
84
|
apps = command.run
|
76
85
|
|
77
|
-
assert_instance_of
|
78
|
-
assert_equal
|
86
|
+
assert_instance_of CfScript::AppList, apps
|
87
|
+
assert_equal CfScript::AppList.new, apps
|
79
88
|
end
|
80
89
|
end
|
81
90
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe 'DeleteCommand' do
|
4
|
+
include MockExecution
|
5
|
+
|
6
|
+
let(:command) { CfScript::Command::Apps::DeleteCommand.instance }
|
7
|
+
|
8
|
+
it_behaves_like 'a command object that', {
|
9
|
+
has_type: :apps,
|
10
|
+
has_name: :delete,
|
11
|
+
fails_with: false
|
12
|
+
}
|
13
|
+
|
14
|
+
it "returns true on success" do
|
15
|
+
fake_cf do
|
16
|
+
assert_equal true, command.run(:name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "prints an error on failure" do
|
21
|
+
fake_cf delete: :not_exist do |stdout, stderr|
|
22
|
+
command.run(:name)
|
23
|
+
|
24
|
+
assert_match /\{delete\} failed to delete app/, stderr.lines.first
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "skips flags when false" do
|
29
|
+
assert_command_args command,
|
30
|
+
[:worker],
|
31
|
+
[:worker, { flags: [] }]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "adds flag for force when true" do
|
35
|
+
assert_command_args command,
|
36
|
+
[:worker, true],
|
37
|
+
[:worker, { flags: [:f] }]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "adds flag for delete routes when true" do
|
41
|
+
assert_command_args command,
|
42
|
+
[:worker, false, true],
|
43
|
+
[:worker, { flags: [:r] }]
|
44
|
+
end
|
45
|
+
|
46
|
+
it "adds flags for force and delete routes when true" do
|
47
|
+
assert_command_args command,
|
48
|
+
[:worker, true, true],
|
49
|
+
[:worker, { flags: [:f, :r] }]
|
50
|
+
end
|
51
|
+
end
|
@@ -47,9 +47,19 @@ describe 'EnvCommand' do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
it "returns an empty Hash
|
50
|
+
it "returns an empty Hash if the output is empty" do
|
51
51
|
fake_cf env: :empty do
|
52
|
-
|
52
|
+
result = command.run(:worker)
|
53
|
+
|
54
|
+
assert_equal({}, result)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns an empty Hash when no env variables are found" do
|
59
|
+
fake_cf env: :empty_vars do
|
60
|
+
result = command.run(:worker)
|
61
|
+
|
62
|
+
assert_equal({}, result)
|
53
63
|
end
|
54
64
|
end
|
55
65
|
end
|
@@ -19,6 +19,14 @@ describe 'PushCommand' do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
it "returns nil if no attributes were found" do
|
23
|
+
fake_cf push: :empty do
|
24
|
+
result = command.run(:api)
|
25
|
+
|
26
|
+
assert_equal nil, result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
it "translates long option names to cf's short ones" do
|
23
31
|
fake_cf do
|
24
32
|
assert_equal({ f: 'a' }, command.translate_options({ manifest: 'a' }))
|
@@ -43,4 +51,10 @@ describe 'PushCommand' do
|
|
43
51
|
)
|
44
52
|
end
|
45
53
|
end
|
54
|
+
|
55
|
+
it "builds options and flag for run_cf" do
|
56
|
+
assert_command_args command,
|
57
|
+
[:worker, i: 2, memory: '123', command: './run', flags: [:no_start]],
|
58
|
+
[:worker, { i: 2, m: '123', c: './run', flags: [:no_start] }]
|
59
|
+
end
|
46
60
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe 'RenameCommand' do
|
4
|
+
include MockExecution
|
5
|
+
|
6
|
+
let(:command) { CfScript::Command::Apps::RenameCommand.instance }
|
7
|
+
|
8
|
+
it_behaves_like 'a command object that', {
|
9
|
+
has_type: :apps,
|
10
|
+
has_name: :rename,
|
11
|
+
fails_with: false
|
12
|
+
}
|
13
|
+
|
14
|
+
it "returns true on success" do
|
15
|
+
fake_cf do
|
16
|
+
assert_equal true, command.run(:old, :new)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "prints an error on failure" do
|
21
|
+
fake_cf rename: :not_found do |stdout, stderr|
|
22
|
+
command.run(:old, :new)
|
23
|
+
|
24
|
+
assert_match /\{rename\} failed to rename/, stderr.lines.first
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false when the app is not found" do
|
29
|
+
fake_cf rename: :not_found do |stdout, stderr|
|
30
|
+
assert_equal false, command.run(:old, :new)
|
31
|
+
|
32
|
+
assert_match /\{rename\} failed to rename/, stderr.lines.first
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -39,6 +39,14 @@ describe 'RestageCommand' do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
it "returns nil if no attributes were found" do
|
43
|
+
fake_cf restage: :empty do
|
44
|
+
result = command.run(:api)
|
45
|
+
|
46
|
+
assert_equal nil, result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
it "returns nil on failure" do
|
43
51
|
fake_cf restage: :not_found do
|
44
52
|
assert_equal nil, command.run(:some_app)
|
@@ -39,6 +39,14 @@ describe 'RestartCommand' do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
it "returns nil if no attributes were found" do
|
43
|
+
fake_cf restart: :empty do
|
44
|
+
result = command.run(:worker)
|
45
|
+
|
46
|
+
assert_equal nil, result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
it "returns nil on failure" do
|
43
51
|
fake_cf restart: :not_found do
|
44
52
|
assert_equal nil, command.run(:some_app)
|
@@ -47,6 +47,14 @@ describe 'StartCommand' do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
it "returns nil if no attributes were found" do
|
51
|
+
fake_cf start: :empty do
|
52
|
+
result = command.run(:worker)
|
53
|
+
|
54
|
+
assert_equal nil, result
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
50
58
|
it "returns nil on failure" do
|
51
59
|
fake_cf start: :not_found do
|
52
60
|
assert_equal nil, command.run(:some_app)
|
@@ -13,7 +13,7 @@ describe 'StopCommand' do
|
|
13
13
|
|
14
14
|
it "returns true on success" do
|
15
15
|
fake_cf do
|
16
|
-
|
16
|
+
assert_equal true, command.run(:worker)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -27,7 +27,7 @@ describe 'StopCommand' do
|
|
27
27
|
|
28
28
|
it "returns false when the app is not found" do
|
29
29
|
fake_cf stop: :not_found do |stdout, stderr|
|
30
|
-
|
30
|
+
assert_equal false, command.run(:bogus)
|
31
31
|
|
32
32
|
assert_match /\{stop\} failed to stop/, stderr.lines.first
|
33
33
|
end
|