2021-06-30 13:27:03 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2016-01-25 19:07:14 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
2016-12-06 23:20:29 +01:00
|
|
|
shared_context 'unit' do
|
2016-01-25 19:07:14 +00:00
|
|
|
include_context 'vagrant-unit'
|
|
|
|
|
|
2020-12-05 15:24:42 +00:00
|
|
|
let(:vagrantfile_providerconfig) { '' }
|
2016-12-06 23:20:29 +01:00
|
|
|
let(:vagrantfile) do
|
|
|
|
|
<<-EOF
|
2016-01-25 19:07:14 +00:00
|
|
|
Vagrant.configure('2') do |config|
|
2021-09-28 13:17:22 +01:00
|
|
|
config.vm.box = "vagrant-libvirt/test"
|
2016-01-25 19:07:14 +00:00
|
|
|
config.vm.define :test
|
2020-12-05 15:24:42 +00:00
|
|
|
config.vm.provider :libvirt do |libvirt|
|
|
|
|
|
#{vagrantfile_providerconfig}
|
|
|
|
|
end
|
2016-01-25 19:07:14 +00:00
|
|
|
end
|
|
|
|
|
EOF
|
2016-04-27 16:27:39 +01:00
|
|
|
end
|
|
|
|
|
let(:test_env) do
|
2016-01-25 19:07:14 +00:00
|
|
|
test_env = isolated_environment
|
|
|
|
|
test_env.vagrantfile vagrantfile
|
|
|
|
|
test_env
|
|
|
|
|
end
|
|
|
|
|
let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
|
2016-12-06 23:20:29 +01:00
|
|
|
let(:conf) { Vagrant::Config::V2::DummyConfig.new }
|
2020-10-23 14:31:29 +01:00
|
|
|
let(:ui) { Vagrant::UI::Silent.new }
|
2016-01-25 19:07:14 +00:00
|
|
|
let(:iso_env) { test_env.create_vagrant_env ui_class: Vagrant::UI::Basic }
|
|
|
|
|
let(:machine) { iso_env.machine(:test, :libvirt) }
|
|
|
|
|
# Mock the communicator to prevent SSH commands for being executed.
|
|
|
|
|
let(:communicator) { double('communicator') }
|
|
|
|
|
# Mock the guest operating system.
|
|
|
|
|
let(:guest) { double('guest') }
|
2016-12-06 23:20:29 +01:00
|
|
|
let(:app) { ->(env) {} }
|
|
|
|
|
let(:plugin) { register_plugin }
|
2016-01-25 19:07:14 +00:00
|
|
|
|
|
|
|
|
before (:each) do
|
2020-08-16 16:06:05 +01:00
|
|
|
allow(machine).to receive(:guest).and_return(guest)
|
2021-11-04 10:55:51 +00:00
|
|
|
allow(machine).to receive(:communicate).and_return(communicator)
|
2016-01-25 19:07:14 +00:00
|
|
|
end
|
|
|
|
|
end
|