cf_script 0.0.1 → 0.0.2
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 +5 -6
- data/CHANGELOG.md +11 -0
- data/README.md +9 -7
- data/lib/cf_script/command/base.rb +8 -4
- data/lib/cf_script/command/cf/apps.rb +4 -0
- data/lib/cf_script/command/cf/apps/restart_app_instance.rb +20 -0
- data/lib/cf_script/command/cf/apps/scale.rb +39 -0
- data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
- data/lib/cf_script/command/cf/spaces/space.rb +1 -1
- data/lib/cf_script/command/registry.rb +1 -1
- data/lib/cf_script/command/runner.rb +6 -4
- data/lib/cf_script/executor/simple.rb +1 -1
- data/lib/cf_script/object/app_info.rb +8 -8
- data/lib/cf_script/output/buffer.rb +1 -1
- data/lib/cf_script/output/parser/attributes.rb +1 -1
- data/lib/cf_script/output/tests.rb +6 -6
- data/lib/cf_script/scope/app/state.rb +12 -0
- data/lib/cf_script/scope/script.rb +1 -1
- data/lib/cf_script/version.rb +1 -1
- data/test/fixtures/commands/apps/restart_app_instance/good.yml +8 -0
- data/test/fixtures/commands/apps/restart_app_instance/not_found.yml +8 -0
- data/test/fixtures/commands/apps/scale/good.yml +8 -0
- data/test/lib/cf_script/command/base_test.rb +127 -2
- data/test/lib/cf_script/command/cf/apps/app_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/delete_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/push_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/rename_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/restage_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/restart_app_instance_test.rb +41 -0
- data/test/lib/cf_script/command/cf/apps/restart_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/scale_test.rb +51 -0
- data/test/lib/cf_script/command/cf/apps/set_env_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/start_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/unset_env_test.rb +1 -1
- data/test/lib/cf_script/command/cf/general/api_test.rb +3 -3
- data/test/lib/cf_script/command/cf/general/target_test.rb +2 -2
- data/test/lib/cf_script/command/cf/routes/map_route_test.rb +6 -6
- data/test/lib/cf_script/command/cf/routes/routes_test.rb +1 -1
- data/test/lib/cf_script/command/cf/spaces/space_test.rb +1 -1
- data/test/lib/cf_script/command/cf/spaces/spaces_test.rb +1 -1
- data/test/lib/cf_script/command/line_test.rb +16 -8
- data/test/lib/cf_script/command/registry_test.rb +53 -0
- data/test/lib/cf_script/object/api_endpoint_test.rb +2 -2
- data/test/lib/cf_script/object/app_info_test.rb +13 -13
- data/test/lib/cf_script/object/instance_status_test.rb +7 -7
- data/test/lib/cf_script/object/space_test.rb +1 -1
- data/test/lib/cf_script/object/target_test.rb +1 -1
- data/test/lib/cf_script/output/buffer_test.rb +1 -1
- data/test/lib/cf_script/output/parser/section_test.rb +1 -1
- data/test/lib/cf_script/output/parser/table_test.rb +1 -1
- data/test/lib/cf_script/scope/app/state_test.rb +34 -0
- data/test/lib/cf_script/scope/app_test.rb +5 -1
- data/test/lib/cf_script/ui_test.rb +3 -3
- data/test/support/helpers/object_helpers.rb +4 -4
- data/test/support/shared_examples/command_object.rb +17 -3
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd6cd4eb945b6b74fff8b461e908883512e809bc
|
4
|
+
data.tar.gz: d549971b2a9657953ba7da7c28c6ee35a19a6953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ed916530ac4a0260ef8919e30b8e6599de8df214ddcedb2ce468392a38c6b254e7922d0a9c8b98ba788e0acc13a1cf664340211af5ec94318a4d32c74a7285a
|
7
|
+
data.tar.gz: 9df684146a0a002d47d8150bcc5b9d450893260069f040c25a7021332fbdf8bc33c2ff290292fa66c134d6500819b4f0ea1a9a05481652c58c71d8585e4cd55f
|
data/.travis.yml
CHANGED
@@ -5,14 +5,13 @@ branches:
|
|
5
5
|
- master
|
6
6
|
|
7
7
|
before_script:
|
8
|
-
-
|
9
|
-
- tar -xvf /tmp/cf-linux-
|
8
|
+
- curl -o /tmp/cf-linux-64.tgz https://s3-us-west-1.amazonaws.com/cf-cli-releases/releases/v6.23.1/cf-cli_6.23.1_linux_x86-64.tgz
|
9
|
+
- tar -xvf /tmp/cf-linux-64.tgz
|
10
10
|
- export PATH=$PATH:$PWD/
|
11
11
|
|
12
12
|
rvm:
|
13
|
-
- '2.
|
14
|
-
- '2.
|
15
|
-
- '2.
|
16
|
-
- '2.3.0'
|
13
|
+
- '2.2.6'
|
14
|
+
- '2.3.3'
|
15
|
+
- '2.4.0'
|
17
16
|
|
18
17
|
script: 'bundle exec rake test'
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.0.1](https://github.com/ammar/cf_script/tree/v0.0.1) (2016-01-17)
|
4
|
+
- Added `rename` and `delete` commands
|
5
|
+
- One, simple, PTY-based executor
|
6
|
+
- Echo `cf`'s output by default (`show_output` config option)
|
7
|
+
- Correctly handle `push` with `--no-start`
|
8
|
+
- _[Commits](https://github.com/ammar/cf_script/compare/v0.0.1.beta.1...v0.0.1)_
|
9
|
+
|
10
|
+
## [v0.0.1.beta.1](https://github.com/ammar/cf_script/tree/v0.0.1.beta.1) (2016-01-01)
|
11
|
+
- First beta release
|
data/README.md
CHANGED
@@ -35,19 +35,19 @@ TRACE=1 ruby example.rb
|
|
35
35
|
---
|
36
36
|
## Requirements
|
37
37
|
|
38
|
-
* `ruby` >= 2.
|
39
|
-
* `cf` >=
|
38
|
+
* `ruby` >= 2.2
|
39
|
+
* `cf` >= 6.0
|
40
40
|
|
41
41
|
---
|
42
42
|
## Install
|
43
43
|
|
44
44
|
Install the gem with:
|
45
45
|
|
46
|
-
```gem install cf_script
|
46
|
+
```gem install cf_script```
|
47
47
|
|
48
48
|
Or, add it to your project's `Gemfile`:
|
49
49
|
|
50
|
-
```gem 'cf_script'
|
50
|
+
```gem 'cf_script'```
|
51
51
|
|
52
52
|
---
|
53
53
|
## Execution Scopes
|
@@ -120,12 +120,12 @@ end
|
|
120
120
|
|
121
121
|
The `app` method accepts a string or an AppInfo object as a name argument.
|
122
122
|
|
123
|
-
## Command Methods
|
124
123
|
|
125
124
|
### The `apps` Method
|
126
125
|
The `apps` method mirrors the `cf apps` command. When called without a block,
|
127
|
-
it returns an AppList
|
128
|
-
|
126
|
+
it returns an [AppList](https://github.com/ammar/cf_script/blob/master/lib/cf_script/object/app_list.rb)
|
127
|
+
object that acts as an array of [AppInfo](https://github.com/ammar/cf_script/blob/master/lib/cf_script/object/app_info.rb)
|
128
|
+
objects, each of which contains the information in each row output by `cf apps`.
|
129
129
|
|
130
130
|
```ruby
|
131
131
|
cf do
|
@@ -181,11 +181,13 @@ end
|
|
181
181
|
|   restart | `cf restart APP_NAME` | ✓ |
|
182
182
|
|   push | `cf push APP_NAME [OPTIONS]` | ✓ |
|
183
183
|
|   restage | `cf restage APP_NAME` | ✓ |
|
184
|
+
|   scale | `cf scale APP_NAME [OPTIONS]` | ✓ |
|
184
185
|
|   rename | `cf rename APP_NAME NEW_APP_NAME` | ✓ |
|
185
186
|
|   delete | `cf delete APP_NAME [-f -r]` | ✓ |
|
186
187
|
|   env | `cf env APP_NAME` | ✓ |
|
187
188
|
|   set-env | `cf set-env APP_NAME VAR_NAME VAR_VALUE` | ✓ |
|
188
189
|
|   unset-env | `cf unset-env APP_NAME VAR_NAME` | ✓ |
|
190
|
+
|   restart-app-instance | `cf restart-app-instance APP_NAME INDEX` | ✓ |
|
189
191
|
| _**Routes**_ | | |
|
190
192
|
|   routes | `cf routes` | ✓ |
|
191
193
|
|   check-route | `cf check-route HOST DOMAIN` | ✓ |
|
@@ -25,13 +25,17 @@ module CfScript::Command
|
|
25
25
|
raise "run called in base command class"
|
26
26
|
end
|
27
27
|
|
28
|
+
def option_value(options, key, default)
|
29
|
+
options.key?(key) ? options[key] : default
|
30
|
+
end
|
31
|
+
|
28
32
|
def good_run?(output, options = {})
|
29
|
-
options[:check_status] = options
|
30
|
-
options[:check_failed] = options
|
33
|
+
options[:check_status] = option_value(options, :check_status, true)
|
34
|
+
options[:check_failed] = option_value(options, :check_failed, true)
|
31
35
|
|
32
36
|
if options[:check_status] == true && !output.good?
|
33
37
|
error 'cf exited with error'
|
34
|
-
output.dump
|
38
|
+
output.dump unless CfScript.config.runtime.echo_output
|
35
39
|
return false
|
36
40
|
end
|
37
41
|
|
@@ -47,7 +51,7 @@ module CfScript::Command
|
|
47
51
|
|
48
52
|
if options[:check_failed] == true && output.failed?
|
49
53
|
error 'FAILED'
|
50
|
-
output.dump
|
54
|
+
output.dump unless CfScript.config.runtime.echo_output
|
51
55
|
return false
|
52
56
|
end
|
53
57
|
|
@@ -37,11 +37,13 @@ require 'cf_script/command/cf/apps/stop'
|
|
37
37
|
require 'cf_script/command/cf/apps/restart'
|
38
38
|
require 'cf_script/command/cf/apps/push'
|
39
39
|
require 'cf_script/command/cf/apps/restage'
|
40
|
+
require 'cf_script/command/cf/apps/scale'
|
40
41
|
require 'cf_script/command/cf/apps/env'
|
41
42
|
require 'cf_script/command/cf/apps/set_env'
|
42
43
|
require 'cf_script/command/cf/apps/unset_env'
|
43
44
|
require 'cf_script/command/cf/apps/rename'
|
44
45
|
require 'cf_script/command/cf/apps/delete'
|
46
|
+
require 'cf_script/command/cf/apps/restart_app_instance'
|
45
47
|
|
46
48
|
module CfScript::Command::Apps
|
47
49
|
CfScript::Command.register AppsCommand
|
@@ -51,9 +53,11 @@ module CfScript::Command::Apps
|
|
51
53
|
CfScript::Command.register RestartCommand
|
52
54
|
CfScript::Command.register PushCommand
|
53
55
|
CfScript::Command.register RestageCommand
|
56
|
+
CfScript::Command.register ScaleCommand
|
54
57
|
CfScript::Command.register EnvCommand
|
55
58
|
CfScript::Command.register SetEnvCommand
|
56
59
|
CfScript::Command.register UnsetEnvCommand
|
57
60
|
CfScript::Command.register RenameCommand
|
58
61
|
CfScript::Command.register DeleteCommand
|
62
|
+
CfScript::Command.register RestartAppInstanceCommand
|
59
63
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CfScript::Command
|
2
|
+
class Apps::RestartAppInstanceCommand < CfScript::Command::Apps::Base
|
3
|
+
def initialize
|
4
|
+
super(:apps, :restart_app_instance)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(app_name, instance_index, &block)
|
8
|
+
run_cf self, app_name, instance_index do |output|
|
9
|
+
return false unless good_run?(output, check_failed: false)
|
10
|
+
|
11
|
+
if output.ok?
|
12
|
+
block_given? ? yield(true) : true
|
13
|
+
else
|
14
|
+
error "failed to restart app instance #{instance_index}"
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module CfScript::Command
|
2
|
+
class Apps::ScaleCommand < CfScript::Command::Apps::Base
|
3
|
+
LONG_OPTIONS_MAP = {
|
4
|
+
force_restart: :f,
|
5
|
+
instances: :i,
|
6
|
+
disk: :k,
|
7
|
+
memory: :m,
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super(:apps, :scale)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(app_name, options = {}, &block)
|
15
|
+
run_cf self, app_name, translate_options(options) do |output|
|
16
|
+
return unless good_run?(output, check_failed: false)
|
17
|
+
|
18
|
+
if output.ok?
|
19
|
+
block_given? ? yield(true) : true
|
20
|
+
else
|
21
|
+
error "failed to scale app"
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def translate_options(options)
|
28
|
+
opts = options.dup
|
29
|
+
|
30
|
+
LONG_OPTIONS_MAP.each do |long, short|
|
31
|
+
if opts.key?(long)
|
32
|
+
opts[short] = opts.delete(long)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
opts
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -8,7 +8,7 @@ module CfScript::Command
|
|
8
8
|
run_cf self, host, domain do |output|
|
9
9
|
return false unless good_run?(output)
|
10
10
|
|
11
|
-
exists = output.matches?
|
11
|
+
exists = output.matches?(/^Route #{host}.#{domain} does exist/)
|
12
12
|
|
13
13
|
block_given? ? yield(exists) : exists
|
14
14
|
end
|
@@ -33,19 +33,21 @@ module CfScript::Command
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def cf_path
|
36
|
+
@cf_path = nil unless defined? @cf_path
|
37
|
+
|
36
38
|
unless @cf_path
|
37
39
|
@cf_path = ENV['CF_BINARY'] || which_cf
|
38
40
|
|
39
41
|
if @cf_path.nil? || @cf_path.empty?
|
40
42
|
puts "Could not find the cf binary".colorize(:red)
|
41
43
|
puts
|
42
|
-
puts "If it isn't installed you need to install it first. You can
|
43
|
-
puts "the latest release at:"
|
44
|
+
puts "If it isn't installed you need to install it first. You can "
|
45
|
+
puts "find the latest release at:"
|
44
46
|
puts
|
45
47
|
puts " https://github.com/cloudfoundry/cli/releases".colorize(:cyan)
|
46
48
|
puts
|
47
|
-
puts "If cf is already installed, make sure its location is
|
48
|
-
puts "in $PATH."
|
49
|
+
puts "If cf is already installed, make sure its location is "
|
50
|
+
puts "included in $PATH."
|
49
51
|
|
50
52
|
raise "Could not find the cf binary"
|
51
53
|
end
|
@@ -41,18 +41,18 @@ class CfScript::AppInfo
|
|
41
41
|
alias :cold? :stopped?
|
42
42
|
|
43
43
|
def update(attrs)
|
44
|
-
@requested_state = attrs[:requested_state].value
|
45
|
-
@instances = attrs[:instances].value
|
44
|
+
@requested_state = attrs.key?(:requested_state) ? attrs[:requested_state].value : nil
|
45
|
+
@instances = attrs.key?(:instances) ? attrs[:instances].value : nil
|
46
46
|
|
47
47
|
@urls = attrs.key?(:urls) ? attrs[:urls].to_a : []
|
48
48
|
|
49
|
-
@usage = attrs[:usage].value
|
50
|
-
@last_uploaded = attrs[:last_uploaded].value
|
51
|
-
@stack = attrs[:stack].value
|
52
|
-
@buildpack = attrs[:buildpack].value
|
49
|
+
@usage = attrs.key?(:usage) ? attrs[:usage].value : nil
|
50
|
+
@last_uploaded = attrs.key?(:last_uploaded) ? attrs[:last_uploaded].value : nil
|
51
|
+
@stack = attrs.key?(:stack) ? attrs[:stack].value : nil
|
52
|
+
@buildpack = attrs.key?(:buildpack) ? attrs[:buildpack].value : nil
|
53
53
|
|
54
|
-
@memory = attrs[:memory].value
|
55
|
-
@disk = attrs[:disk].value
|
54
|
+
@memory = attrs.key?(:memory) ? attrs[:memory].value : nil
|
55
|
+
@disk = attrs.key?(:disk) ? attrs[:disk].value : nil
|
56
56
|
|
57
57
|
if @memory.nil? and @usage
|
58
58
|
@memory = @usage.split(' ').first
|
@@ -9,11 +9,11 @@ module CfScript
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def ok?
|
12
|
-
out.last_line_matches?
|
12
|
+
out.last_line_matches?(/^OK$/)
|
13
13
|
end
|
14
14
|
|
15
15
|
def authenticated?
|
16
|
-
matches?
|
16
|
+
matches?(/Authenticating\.\.\.\nOK/m)
|
17
17
|
end
|
18
18
|
|
19
19
|
def failed?
|
@@ -21,7 +21,7 @@ module CfScript
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def no_api_endpoint?
|
24
|
-
contains? 'No API endpoint set
|
24
|
+
contains? 'No API endpoint set'
|
25
25
|
end
|
26
26
|
|
27
27
|
def not_logged_in?
|
@@ -37,15 +37,15 @@ module CfScript
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def not_found?(type, name)
|
40
|
-
out.last_line_matches?
|
40
|
+
out.last_line_matches?(/#{type} #{name} not found/)
|
41
41
|
end
|
42
42
|
|
43
43
|
def is_already?(name, state)
|
44
|
-
out.last_line_matches?
|
44
|
+
out.last_line_matches?(/#{name} is already #{state}/)
|
45
45
|
end
|
46
46
|
|
47
47
|
def already_exists?(type, name)
|
48
|
-
out.last_line_matches?
|
48
|
+
out.last_line_matches?(/#{type} #{name} already exists/)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -29,5 +29,17 @@ module CfScript::Scope
|
|
29
29
|
@app_info = app_info if app_info
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
def scale(options)
|
34
|
+
CfScript::Command.scale name, options do |scaled|
|
35
|
+
cf_self
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def restart_instance(index)
|
40
|
+
CfScript::Command.restart_app_instance name, index do |restarted|
|
41
|
+
cf_self
|
42
|
+
end
|
43
|
+
end
|
32
44
|
end
|
33
45
|
end
|
@@ -32,7 +32,7 @@ module CfScript::Scope
|
|
32
32
|
|
33
33
|
# If api is given and there are no username or password, set the api
|
34
34
|
if options[:api] and (options[:username].nil? or options[:password].nil?)
|
35
|
-
unless
|
35
|
+
unless CfScript::Command.api(options[:api])
|
36
36
|
error :cf, "Could not set the API endpoint: #{options[:api]}"
|
37
37
|
raise "Could not set the API endpoint: #{options[:api]}"
|
38
38
|
end
|
data/lib/cf_script/version.rb
CHANGED
@@ -1,21 +1,146 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
describe CfScript::Command::Base do
|
4
|
+
include MockExecution
|
5
|
+
|
4
6
|
class TestCommand < CfScript::Command::Base
|
5
7
|
def initialize
|
6
8
|
super(:test, :dummy)
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
12
|
+
subject { TestCommand.instance }
|
13
|
+
|
10
14
|
it "defines a line method that returns a Command::Line object" do
|
11
|
-
line =
|
15
|
+
line = subject.line({}, 'cf', [])
|
12
16
|
|
13
17
|
assert_instance_of CfScript::Command::Line, line
|
14
18
|
end
|
15
19
|
|
16
20
|
it "raises an exception if run is called" do
|
17
21
|
assert_raises(RuntimeError) {
|
18
|
-
|
22
|
+
subject.run
|
19
23
|
}
|
20
24
|
end
|
25
|
+
|
26
|
+
describe "option_value" do
|
27
|
+
it "returns option value if present" do
|
28
|
+
options = { test: true }
|
29
|
+
|
30
|
+
result = subject.option_value(options, :test, false)
|
31
|
+
|
32
|
+
assert_equal true, result
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns default value if option is not present" do
|
36
|
+
options = {}
|
37
|
+
|
38
|
+
result = subject.option_value(options, :test, false)
|
39
|
+
|
40
|
+
assert_equal false, result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "good_run?" do
|
45
|
+
describe "exit status is zero" do
|
46
|
+
it "returns true" do
|
47
|
+
output = fake_output
|
48
|
+
|
49
|
+
assert_equal true, subject.good_run?(output)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "exit status is not zero" do
|
54
|
+
before { @output = fake_output('', '', 1) }
|
55
|
+
|
56
|
+
it "returns false" do
|
57
|
+
fake_io do |stdout, stderr|
|
58
|
+
assert_equal false, subject.good_run?(@output)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "prints an error message" do
|
63
|
+
fake_io do |stdout, stderr|
|
64
|
+
subject.good_run?(@output)
|
65
|
+
|
66
|
+
assert_match(/\{dummy\}/, stderr.lines.last)
|
67
|
+
assert_match(/cf exited with error/, stderr.lines.last)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "and check_status is false" do
|
72
|
+
it "returns true" do
|
73
|
+
fake_io do |stdout, stderr|
|
74
|
+
result = subject.good_run?(@output, check_status: false)
|
75
|
+
|
76
|
+
assert_equal true, result
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "doesn't print an error message" do
|
81
|
+
fake_io do |stdout, stderr|
|
82
|
+
subject.good_run?(@output, check_status: false)
|
83
|
+
|
84
|
+
assert_equal 0, stderr.lines.length
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "output contains FAILED" do
|
91
|
+
before { @output = fake_output('FAILED') }
|
92
|
+
|
93
|
+
it "returns false" do
|
94
|
+
fake_io do |stdout, stderr|
|
95
|
+
assert_equal false, subject.good_run?(@output)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it "returns true when check_failed is false" do
|
100
|
+
fake_io do |stdout, stderr|
|
101
|
+
result = subject.good_run?(@output, check_failed: false)
|
102
|
+
|
103
|
+
assert_equal true, result
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "output contains 'No API endpoint set'" do
|
109
|
+
before { @output = fake_output('No API endpoint set') }
|
110
|
+
|
111
|
+
it "returns false" do
|
112
|
+
fake_io do |stdout, stderr|
|
113
|
+
assert_equal false, subject.good_run?(@output)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "prints an error message" do
|
118
|
+
fake_io do |stdout, stderr|
|
119
|
+
subject.good_run?(@output)
|
120
|
+
|
121
|
+
assert_match(/\{dummy\}/, stderr.lines.last)
|
122
|
+
assert_match(/No API endpoint set/, stderr.lines.last)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "output contains 'Not logged in'" do
|
128
|
+
before { @output = fake_output('Not logged in') }
|
129
|
+
|
130
|
+
it "returns false" do
|
131
|
+
fake_io do |stdout, stderr|
|
132
|
+
assert_equal false, subject.good_run?(@output)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it "prints an error message" do
|
137
|
+
fake_io do |stdout, stderr|
|
138
|
+
subject.good_run?(@output)
|
139
|
+
|
140
|
+
assert_match(/\{dummy\}/, stderr.lines.last)
|
141
|
+
assert_match(/Not logged in/, stderr.lines.last)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
21
146
|
end
|