Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add method to abort staging

This provides a hook for staging plugins to abort staging with a message
that will be propagated back to the user.

Test plan:
- Unit test passes

Change-Id: I14cd811a68156ac3305cd22d6a1749c1eafbbfb7
  • Loading branch information...
commit d7c51dfa75586b41597df0ee2a0de448e15b93a2 1 parent 493dae6
mpage authored
View
1  stager/lib/vcap/stager/errors.rb
@@ -39,5 +39,6 @@ class PluginRunnerError < Error; end
class MissingFrameworkPluginError < PluginRunnerError; end
class DuplicateFrameworkPluginError < PluginRunnerError; end
class UnknownPluginTypeError < PluginRunnerError; end
+ class StagingAbortedError < PluginRunnerError; end
end
end
View
9 stager/lib/vcap/stager/plugin_action_proxy.rb
@@ -1,3 +1,5 @@
+require 'vcap/stager/errors'
+
module VCAP
module Stager
end
@@ -58,6 +60,13 @@ def droplet_base_dir
@droplet.base_dir
end
+ # Aborts staging for the supplied reason.
+ #
+ # @param reason String Why staging is being aborted
+ def abort_staging(reason)
+ raise VCAP::Stager::StagingAbortedError.new(reason)
+ end
+
private
def create_script(path)
View
24 stager/spec/unit/plugin_action_proxy_spec.rb
@@ -6,6 +6,9 @@
describe VCAP::Stager::PluginActionProxy do
before :each do
@tmpdir = Dir.mktmpdir
+ start_path = File.join(@tmpdir, 'start')
+ stop_path = File.join(@tmpdir, 'stop')
+ @proxy = VCAP::Stager::PluginActionProxy.new(start_path, stop_path, nil, nil, nil)
end
after :each do
@@ -14,17 +17,26 @@
describe '#start_script' do
it 'should return an open file object with mode 755' do
- start_path = File.join(@tmpdir, 'start')
- proxy = VCAP::Stager::PluginActionProxy.new(start_path, nil, nil, nil)
- verify_script(proxy.start_script)
+ verify_script(@proxy.start_script)
end
end
describe '#stop_script' do
it 'should return an open file object with mode 755' do
- stop_path = File.join(@tmpdir, 'stop')
- proxy = VCAP::Stager::PluginActionProxy.new(nil, stop_path, nil, nil)
- verify_script(proxy.stop_script)
+ verify_script(@proxy.stop_script)
+ end
+ end
+
+ describe '#abort_staging' do
+ it 'should raise an instance of VCAP::Stager::StagingAbortedError with the supplied reason' do
+ caught_message = nil
+ reason = "TESTING"
+ begin
+ @proxy.abort_staging(reason)
+ rescue VCAP::Stager::StagingAbortedError => e
+ caught_message = e.to_s
+ end
+ caught_message.should == reason
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.