Merge pull request #11912 from kipal/assume-yes-cloud-version-release
--yes options added to CloudCommand::VersionCommand::Command::Release
This commit is contained in:
commit
4b07f2d1fa
@ -18,6 +18,10 @@ module VagrantPlugins
|
||||
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
|
||||
options[:username] = u
|
||||
end
|
||||
options[:force] = false
|
||||
o.on("-f", "--force", "Release without confirmation") do |f|
|
||||
options[:force] = f
|
||||
end
|
||||
end
|
||||
|
||||
# Parse the options
|
||||
@ -28,9 +32,11 @@ module VagrantPlugins
|
||||
help: opts.help.chomp
|
||||
end
|
||||
|
||||
@env.ui.warn(I18n.t("cloud_command.version.release_warn", version: argv[1], box: argv.first))
|
||||
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
|
||||
return 1 if cont.strip.downcase != "y"
|
||||
if not options[:force]
|
||||
@env.ui.warn(I18n.t("cloud_command.version.release_warn", version: argv[1], box: argv.first))
|
||||
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
|
||||
return 1 if cont.strip.downcase != "y"
|
||||
end
|
||||
|
||||
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
|
||||
box = argv.first.split('/', 2)
|
||||
|
||||
@ -30,8 +30,6 @@ describe VagrantPlugins::CloudCommand::VersionCommand::Command::Release do
|
||||
allow(VagrantCloud::Box).to receive(:new)
|
||||
.with(anything, "box-name", nil, nil, nil, client.token)
|
||||
.and_return(box)
|
||||
allow(iso_env.ui).to receive(:ask).
|
||||
and_return("y")
|
||||
end
|
||||
|
||||
context "with no arguments" do
|
||||
@ -41,9 +39,36 @@ describe VagrantPlugins::CloudCommand::VersionCommand::Command::Release do
|
||||
end
|
||||
end
|
||||
|
||||
context "with arguments" do
|
||||
context "interactive mode with arguments" do
|
||||
let (:argv) { ["vagrant/box-name", "1.0.0"] }
|
||||
|
||||
it "releases a version" do
|
||||
allow(iso_env.ui).to receive(:ask).
|
||||
and_return("y")
|
||||
allow(VagrantCloud::Version).to receive(:new).
|
||||
with(box, "1.0.0", nil, nil, client.token).
|
||||
and_return(version)
|
||||
|
||||
expect(version).to receive(:release).and_return({})
|
||||
expect(subject.execute).to eq(0)
|
||||
end
|
||||
|
||||
it "displays an error if encoutering a problem with the request" do
|
||||
allow(iso_env.ui).to receive(:ask).
|
||||
and_return("y")
|
||||
allow(VagrantCloud::Version).to receive(:new).
|
||||
with(box, "1.0.0", nil, nil, client.token).
|
||||
and_return(version)
|
||||
|
||||
allow(version).to receive(:release).
|
||||
and_raise(VagrantCloud::ClientError.new("Fail Message", "Message", 404))
|
||||
expect(subject.execute).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "non-interactive mode with arguments" do
|
||||
let (:argv) { ["--force", "vagrant/box-name", "1.0.0"] }
|
||||
|
||||
it "releases a version" do
|
||||
allow(VagrantCloud::Version).to receive(:new).
|
||||
with(box, "1.0.0", nil, nil, client.token).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user