silver_spurs 2.0.0.rc4 → 2.0.0.rc5
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.
@@ -15,14 +15,20 @@ module SilverSpurs
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def convert_status(response)
|
18
|
-
|
19
|
-
|
18
|
+
code = response[0]
|
19
|
+
case code
|
20
|
+
when 'ok'
|
21
|
+
:success
|
22
|
+
when 'error'
|
23
|
+
:failed
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def prettify_log(response)
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
run_info = response[1]
|
29
|
+
stdout = run_info['stdout']
|
30
|
+
stderr = run_info['stderr']
|
31
|
+
exit_code = run_info['exit_code'] || run_info['exit_status']
|
26
32
|
|
27
33
|
template = ERB.new <<-END
|
28
34
|
Exit Code: <%= exit_code %>
|
data/lib/silver_spurs/version.rb
CHANGED
@@ -3,16 +3,16 @@ require 'silver_spurs/client/chef_output'
|
|
3
3
|
describe SilverSpurs::ChefOutput do
|
4
4
|
describe :convert_status do
|
5
5
|
before :each do
|
6
|
-
@chef_run = SilverSpurs::ChefOutput.new({'stdout' => '', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0})
|
6
|
+
@chef_run = SilverSpurs::ChefOutput.new(['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0}])
|
7
7
|
end
|
8
8
|
|
9
9
|
def call_convert_status(response)
|
10
10
|
@chef_run.send(:convert_status, response)
|
11
11
|
end
|
12
12
|
|
13
|
-
context '
|
13
|
+
context 'response is "ok"' do
|
14
14
|
before :each do
|
15
|
-
@response =
|
15
|
+
@response = ["ok", {}]
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return :success" do
|
@@ -20,14 +20,9 @@ describe SilverSpurs::ChefOutput do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
context '
|
23
|
+
context 'response is "error"' do
|
24
24
|
it "should return :failed" do
|
25
|
-
@response =
|
26
|
-
call_convert_status(@response).should eq :failed
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return :failed" do
|
30
|
-
@response = { 'exit_code' => 1, 'exit_status' => 0}
|
25
|
+
@response = ["error", {}]
|
31
26
|
call_convert_status(@response).should eq :failed
|
32
27
|
end
|
33
28
|
end
|
@@ -36,7 +31,7 @@ describe SilverSpurs::ChefOutput do
|
|
36
31
|
|
37
32
|
describe :prettify_log do
|
38
33
|
before :each do
|
39
|
-
@chef_run = SilverSpurs::ChefOutput.new({'stdout' => '', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0})
|
34
|
+
@chef_run = SilverSpurs::ChefOutput.new(['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0}])
|
40
35
|
end
|
41
36
|
|
42
37
|
def call_prettify_log(response)
|
@@ -44,39 +39,39 @@ describe SilverSpurs::ChefOutput do
|
|
44
39
|
end
|
45
40
|
|
46
41
|
it 'should output stderr' do
|
47
|
-
response = {'stdout' => '', 'stderr' => 'stdERR, son', 'exit_code' => 0, 'exit_status' => 0}
|
42
|
+
response = ['ok', {'stdout' => '', 'stderr' => 'stdERR, son', 'exit_code' => 0, 'exit_status' => 0}]
|
48
43
|
call_prettify_log(response).should match(/stdERR, son/)
|
49
44
|
end
|
50
45
|
|
51
46
|
it 'should output stdout' do
|
52
|
-
response = {'stdout' => 'stdOUT, son', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0}
|
47
|
+
response = ['ok', {'stdout' => 'stdOUT, son', 'stderr' => '', 'exit_code' => 0, 'exit_status' => 0}]
|
53
48
|
call_prettify_log(response).should match(/stdOUT, son/)
|
54
49
|
end
|
55
50
|
|
56
51
|
context 'when exit_code and exit_status are present' do
|
57
52
|
it 'should prefer exit_code' do
|
58
|
-
response = {'stdout' => '', 'stderr' => '', 'exit_code' => 1, 'exit_status' => 2}
|
53
|
+
response = ['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => 1, 'exit_status' => 2}]
|
59
54
|
call_prettify_log(response).should match(/Exit Code: 1/)
|
60
55
|
end
|
61
56
|
end
|
62
57
|
|
63
58
|
context 'when exit_code is not present' do
|
64
59
|
it 'should use exit_status' do
|
65
|
-
response = {'stdout' => '', 'stderr' => '', 'exit_code' => nil, 'exit_status' => 2}
|
60
|
+
response = ['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => nil, 'exit_status' => 2}]
|
66
61
|
call_prettify_log(response).should match(/Exit Code: 2/)
|
67
62
|
end
|
68
63
|
end
|
69
64
|
|
70
65
|
context 'when exit_status is not present' do
|
71
66
|
it 'should use exit_code' do
|
72
|
-
response = {'stdout' => '', 'stderr' => '', 'exit_code' => 1, 'exit_status' => nil}
|
67
|
+
response = ['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => 1, 'exit_status' => nil}]
|
73
68
|
call_prettify_log(response).should match(/Exit Code: 1/)
|
74
69
|
end
|
75
70
|
end
|
76
71
|
|
77
72
|
context 'when exit_code and exit_status are not present' do
|
78
73
|
it 'should use nil' do
|
79
|
-
response = {'stdout' => '', 'stderr' => '', 'exit_code' => nil, 'exit_status' => nil}
|
74
|
+
response = ['ok', {'stdout' => '', 'stderr' => '', 'exit_code' => nil, 'exit_status' => nil}]
|
80
75
|
call_prettify_log(response).should match(/Exit Code: /)
|
81
76
|
end
|
82
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silver_spurs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|