Merge pull request #4975 from mitchellh/sethvargo/fix_push
Fix push lookups
This commit is contained in:
commit
d43a25af9e
|
@ -21,18 +21,18 @@ module VagrantPlugins
|
|||
|
||||
# Compile all the provider configurations
|
||||
@__defined_pushes.each do |name, tuples|
|
||||
# Capture the strategy so we can use it later. This will be used in
|
||||
# the block iteration for merging/overwriting
|
||||
strategy = name
|
||||
strategy = tuples[0][0] if tuples[0]
|
||||
|
||||
# Find the configuration class for this push
|
||||
config_class = Vagrant.plugin("2").manager.push_configs[strategy]
|
||||
config_class = Vagrant.plugin("2").manager.push_configs[name]
|
||||
config_class ||= Vagrant::Config::V2::DummyConfig
|
||||
|
||||
# Load it up
|
||||
config = config_class.new
|
||||
|
||||
# Capture the strategy so we can use it later. This will be used in
|
||||
# the block iteration for merging/overwriting
|
||||
strategy = name
|
||||
strategy = tuples[0][0] if tuples[0]
|
||||
|
||||
begin
|
||||
tuples.each do |s, b|
|
||||
# Update the strategy if it has changed, reseting the current
|
||||
|
|
|
@ -17,6 +17,7 @@ describe VagrantPlugins::LoginCommand::AddAuthentication do
|
|||
|
||||
before do
|
||||
allow(Vagrant).to receive(:server_url).and_return(server_url)
|
||||
stub_env("ATLAS_TOKEN" => nil)
|
||||
end
|
||||
|
||||
describe "#call" do
|
||||
|
|
|
@ -93,47 +93,9 @@ describe VagrantPlugins::LocalExecPush::Push do
|
|||
end
|
||||
|
||||
describe "#execute!" do
|
||||
let(:exit_code) { 0 }
|
||||
let(:stdout) { "This is the output" }
|
||||
let(:stderr) { "This is the errput" }
|
||||
|
||||
let(:process) do
|
||||
double("process",
|
||||
exit_code: exit_code,
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
||||
.and_return(process)
|
||||
end
|
||||
|
||||
it "creates a subprocess" do
|
||||
expect(Vagrant::Util::Subprocess).to receive(:execute)
|
||||
it "safe execs" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec)
|
||||
expect { subject.execute! }.to_not raise_error
|
||||
end
|
||||
|
||||
it "returns the resulting process" do
|
||||
expect(subject.execute!).to be(process)
|
||||
end
|
||||
|
||||
context "when the exit code is non-zero" do
|
||||
let(:exit_code) { 1 }
|
||||
|
||||
it "raises an exception" do
|
||||
klass = VagrantPlugins::LocalExecPush::Errors::CommandFailed
|
||||
cmd = ["foo", "bar"]
|
||||
|
||||
expect { subject.execute!(*cmd) }.to raise_error(klass) { |error|
|
||||
expect(error.message).to eq(I18n.t("local_exec_push.errors.command_failed",
|
||||
cmd: cmd.join(" "),
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
))
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,6 +83,18 @@ shared_context "unit" do
|
|||
return Pathname.new(d)
|
||||
end
|
||||
|
||||
# Stub the given environment in ENV, without actually touching ENV. Keys and
|
||||
# values are converted to strings because that's how the real ENV works.
|
||||
def stub_env(hash)
|
||||
allow(ENV).to receive(:[]).and_call_original
|
||||
|
||||
hash.each do |key, value|
|
||||
allow(ENV).to receive(:[])
|
||||
.with(key.to_s)
|
||||
.and_return(value.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
# This helper provides temporary environmental variable changes.
|
||||
def with_temp_env(environment)
|
||||
# Build up the new environment, preserving the old values so we
|
||||
|
|
Loading…
Reference in New Issue