Code Review
/
packages
/
precise
/
mcollective.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Update code from https://github.com/dmi-try/marionette-collective
[packages/precise/mcollective.git]
/
spec
/
unit
/
application_spec.rb
diff --git
a/spec/unit/application_spec.rb
b/spec/unit/application_spec.rb
index 9b1c434b5930c7fe2527a722f20b261caebe4135..d2e64eb137e82563369535a8cf1d0f7948963950 100755
(executable)
--- a/
spec/unit/application_spec.rb
+++ b/
spec/unit/application_spec.rb
@@
-414,7
+414,7
@@
module MCollective
describe "#halt" do
before do
describe "#halt" do
before do
- @stats = {:discoverytime => 0, :discovered => 0, :failcount => 0, :responses => 0}
+ @stats = {:discoverytime => 0, :discovered => 0, :failcount => 0, :responses => 0
, :okcount => 0
}
end
it "should exit with code 0 if discovery was done and all responses passed" do
end
it "should exit with code 0 if discovery was done and all responses passed" do
@@
-423,28
+423,25
@@
module MCollective
@stats[:discoverytime] = 2
@stats[:discovered] = 2
@stats[:responses] = 2
@stats[:discoverytime] = 2
@stats[:discovered] = 2
@stats[:responses] = 2
+ @stats[:okcount] = 2
- app.expects(:exit).with(0)
-
- app.halt(@stats)
+ app.halt_code(@stats).should == 0
end
it "should exit with code 0 if no discovery were done but responses were received" do
app = Application.new
@stats[:responses] = 1
end
it "should exit with code 0 if no discovery were done but responses were received" do
app = Application.new
@stats[:responses] = 1
+ @stats[:okcount] = 1
+ @stats[:discovered] = 1
- app.expects(:exit).with(0)
-
- app.halt(@stats)
+ app.halt_code(@stats).should == 0
end
end
- it "should exit with code
0
if discovery info is missing" do
+ it "should exit with code
1
if discovery info is missing" do
app = Application.new
app = Application.new
- app.expects(:exit).with(0)
-
- app.halt({})
+ app.halt_code({}).should == 1
end
it "should exit with code 1 if no nodes were discovered and discovery was done" do
end
it "should exit with code 1 if no nodes were discovered and discovery was done" do
@@
-452,22
+449,29
@@
module MCollective
@stats[:discoverytime] = 2
@stats[:discoverytime] = 2
- app.expects(:exit).with(1)
-
- app.halt(@stats)
+ app.halt_code(@stats).should == 1
end
it "should exit with code 2 if a request failed for some nodes" do
app = Application.new
end
it "should exit with code 2 if a request failed for some nodes" do
app = Application.new
- @stats[:discovered] =
1
+ @stats[:discovered] =
2
@stats[:failcount] = 1
@stats[:discoverytime] = 2
@stats[:failcount] = 1
@stats[:discoverytime] = 2
- @stats[:responses] =
1
+ @stats[:responses] =
2
- app.expects(:exit).with(2)
+ app.halt_code(@stats).should == 2
+ end
+
+ it "should exit with code 2 when no discovery were done and there were failure results" do
+ app = Application.new
- app.halt(@stats)
+ @stats[:discovered] = 1
+ @stats[:failcount] = 1
+ @stats[:discoverytime] = 0
+ @stats[:responses] = 1
+
+ app.halt_code(@stats).should == 2
end
it "should exit with code 3 if no responses were received after discovery" do
end
it "should exit with code 3 if no responses were received after discovery" do
@@
-476,17
+480,13
@@
module MCollective
@stats[:discovered] = 1
@stats[:discoverytime] = 2
@stats[:discovered] = 1
@stats[:discoverytime] = 2
- app.expects(:exit).with(3)
-
- app.halt(@stats)
+ app.halt_code(@stats).should == 3
end
it "should exit with code 4 if no discovery was done and no responses were received" do
app = Application.new
end
it "should exit with code 4 if no discovery was done and no responses were received" do
app = Application.new
- app.expects(:exit).with(4)
-
- app.halt(@stats)
+ app.halt_code(@stats).should == 4
end
end
end
end