2014-10-29 16:39:26 +00:00
|
|
|
require_relative "../../../base"
|
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
require Vagrant.source_root.join("plugins/pushes/atlas/config")
|
|
|
|
require Vagrant.source_root.join("plugins/pushes/atlas/push")
|
2014-10-29 16:39:26 +00:00
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
describe VagrantPlugins::AtlasPush::Push do
|
2014-10-29 16:39:26 +00:00
|
|
|
include_context "unit"
|
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
let(:env) do
|
|
|
|
double("env",
|
|
|
|
root_path: File.expand_path("..", __FILE__)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-10-29 16:39:26 +00:00
|
|
|
let(:config) do
|
2014-11-12 20:49:55 +00:00
|
|
|
VagrantPlugins::AtlasPush::Config.new.tap do |c|
|
2014-10-29 16:39:26 +00:00
|
|
|
c.finalize!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
subject { described_class.new(env, config) }
|
2014-10-29 16:39:26 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
# Stub this right away to avoid real execs
|
|
|
|
allow(Vagrant::Util::SafeExec).to receive(:exec)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#push" do
|
|
|
|
it "pushes with the uploader" do
|
|
|
|
allow(subject).to receive(:uploader_path).and_return("foo")
|
|
|
|
|
|
|
|
expect(subject).to receive(:execute).with("foo")
|
|
|
|
|
|
|
|
subject.push
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception if the uploader couldn't be found" do
|
|
|
|
expect(subject).to receive(:uploader_path).and_return(nil)
|
|
|
|
|
|
|
|
expect { subject.push }.to raise_error(
|
2014-11-12 20:49:55 +00:00
|
|
|
VagrantPlugins::AtlasPush::Errors::UploaderNotFound)
|
2014-10-29 16:39:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#execute" do
|
|
|
|
let(:app) { "foo/bar" }
|
|
|
|
|
|
|
|
before do
|
|
|
|
config.app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends the basic flags" do
|
|
|
|
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
2014-11-12 20:49:55 +00:00
|
|
|
with("foo", "-vcs", app, env.root_path.to_s)
|
2014-10-29 16:39:26 +00:00
|
|
|
|
|
|
|
subject.execute("foo")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't send VCS if disabled" do
|
|
|
|
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
2014-11-12 20:49:55 +00:00
|
|
|
with("foo", app, env.root_path.to_s)
|
2014-10-29 16:39:26 +00:00
|
|
|
|
|
|
|
config.vcs = false
|
|
|
|
subject.execute("foo")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends includes" do
|
|
|
|
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
2014-10-29 16:48:18 +00:00
|
|
|
with("foo", "-vcs", "-include", "foo", "-include",
|
2014-11-12 20:49:55 +00:00
|
|
|
"bar", app, env.root_path.to_s)
|
2014-10-29 16:39:26 +00:00
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
config.includes = ["foo", "bar"]
|
2014-10-29 16:39:26 +00:00
|
|
|
subject.execute("foo")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sends excludes" do
|
|
|
|
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
2014-10-29 16:48:18 +00:00
|
|
|
with("foo", "-vcs", "-exclude", "foo", "-exclude",
|
2014-11-12 20:49:55 +00:00
|
|
|
"bar", app, env.root_path.to_s)
|
2014-10-29 16:39:26 +00:00
|
|
|
|
2014-11-12 20:49:55 +00:00
|
|
|
config.excludes = ["foo", "bar"]
|
2014-10-29 16:39:26 +00:00
|
|
|
subject.execute("foo")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#uploader_path" do
|
|
|
|
it "should return the configured path if set" do
|
|
|
|
config.uploader_path = "foo"
|
|
|
|
expect(subject.uploader_path).to eq("foo")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should look up the uploader via PATH if not set" do
|
|
|
|
allow(Vagrant).to receive(:in_installer?).and_return(false)
|
|
|
|
|
|
|
|
expect(Vagrant::Util::Which).to receive(:which).
|
|
|
|
with(described_class.const_get(:UPLOADER_BIN)).
|
|
|
|
and_return("bar")
|
|
|
|
|
|
|
|
expect(subject.uploader_path).to eq("bar")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should return nil if its not found anywhere" do
|
|
|
|
allow(Vagrant).to receive(:in_installer?).and_return(false)
|
|
|
|
allow(Vagrant::Util::Which).to receive(:which).and_return(nil)
|
|
|
|
|
|
|
|
expect(subject.uploader_path).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|