diff options
Diffstat (limited to 'spec/unit/chef_fs/parallelizer.rb')
-rw-r--r-- | spec/unit/chef_fs/parallelizer.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 971949251c..7823c307f9 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -101,6 +101,20 @@ describe Chef::ChefFS::Parallelizer do elapsed_time.should < 0.4 processed.should == 3 end + + it "Exceptions with :stop_on_exception are raised after all processing is done" do + processed = 0 + parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| + raise 'hi' if x == 'x' + sleep(x) + processed += 1 + x + end + expect { parallelized.to_a }.to raise_error 'hi' + processed.should <= 5 + processed.should >= 2 + end + end context "With :ordered => true (ordered output)" do @@ -154,6 +168,19 @@ describe Chef::ChefFS::Parallelizer do elapsed_time.should < 0.55 processed.should == 3 end + + it "Exceptions with :stop_on_exception are raised after all processing is done" do + processed = 0 + parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :stop_on_exception => true) do |x| + raise 'hi' if x == 'x' + sleep(x) + processed += 1 + x + end + expect { parallelized.to_a }.to raise_error 'hi' + processed.should <= 5 + processed.should >= 2 + end end end |