Add test coverage for all hyper-v configuration options
This commit is contained in:
parent
b1f0f1566d
commit
beacb5bada
|
@ -3,6 +3,9 @@ require_relative "../../../base"
|
|||
require Vagrant.source_root.join("plugins/providers/hyperv/config")
|
||||
|
||||
describe VagrantPlugins::HyperV::Config do
|
||||
|
||||
let(:machine){ double("machine") }
|
||||
|
||||
describe "#ip_address_timeout" do
|
||||
it "can be set" do
|
||||
subject.ip_address_timeout = 180
|
||||
|
@ -30,7 +33,7 @@ describe VagrantPlugins::HyperV::Config do
|
|||
expect(subject.mac).to eq("001122334455")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "#vmname" do
|
||||
it "can be set" do
|
||||
subject.vmname = "test"
|
||||
|
@ -62,4 +65,152 @@ describe VagrantPlugins::HyperV::Config do
|
|||
expect(subject.cpus).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#vmname" do
|
||||
it "can be set" do
|
||||
subject.vmname = "custom"
|
||||
subject.finalize!
|
||||
expect(subject.vmname).to eq("custom")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#differencing_disk" do
|
||||
it "is false by default" do
|
||||
subject.finalize!
|
||||
expect(subject.differencing_disk).to eq(false)
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.differencing_disk = true
|
||||
subject.finalize!
|
||||
expect(subject.differencing_disk).to eq(true)
|
||||
end
|
||||
|
||||
it "should set linked_clone" do
|
||||
subject.differencing_disk = true
|
||||
subject.finalize!
|
||||
expect(subject.differencing_disk).to eq(true)
|
||||
expect(subject.linked_clone).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#linked_clone" do
|
||||
it "is false by default" do
|
||||
subject.finalize!
|
||||
expect(subject.linked_clone).to eq(false)
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.linked_clone = true
|
||||
subject.finalize!
|
||||
expect(subject.linked_clone).to eq(true)
|
||||
end
|
||||
|
||||
it "should set differencing_disk" do
|
||||
subject.linked_clone = true
|
||||
subject.finalize!
|
||||
expect(subject.linked_clone).to eq(true)
|
||||
expect(subject.differencing_disk).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#auto_start_action" do
|
||||
it "should be Nothing by default" do
|
||||
subject.finalize!
|
||||
expect(subject.auto_start_action).to eq("Nothing")
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.auto_start_action = "Start"
|
||||
subject.finalize!
|
||||
expect(subject.auto_start_action).to eq("Start")
|
||||
end
|
||||
|
||||
it "does not accept invalid values" do
|
||||
subject.auto_start_action = "Invalid"
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result["Hyper-V"]).not_to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "#auto_stop_action" do
|
||||
it "should be ShutDown by default" do
|
||||
subject.finalize!
|
||||
expect(subject.auto_stop_action).to eq("ShutDown")
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.auto_stop_action = "Save"
|
||||
subject.finalize!
|
||||
expect(subject.auto_stop_action).to eq("Save")
|
||||
end
|
||||
|
||||
it "does not accept invalid values" do
|
||||
subject.auto_stop_action = "Invalid"
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result["Hyper-V"]).not_to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "#enable_checkpoints" do
|
||||
it "is false by default" do
|
||||
subject.finalize!
|
||||
expect(subject.enable_checkpoints).to eq(false)
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.enable_checkpoints = true
|
||||
subject.finalize!
|
||||
expect(subject.enable_checkpoints).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#enable_virtualization_extensions" do
|
||||
it "is false by default" do
|
||||
subject.finalize!
|
||||
expect(subject.enable_virtualization_extensions).to eq(false)
|
||||
end
|
||||
|
||||
it "can be set" do
|
||||
subject.enable_virtualization_extensions = true
|
||||
subject.finalize!
|
||||
expect(subject.enable_virtualization_extensions).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#vm_integration_services" do
|
||||
it "is empty by default" do
|
||||
subject.finalize!
|
||||
expect(subject.vm_integration_services).to be_empty
|
||||
end
|
||||
|
||||
it "accepts new entries" do
|
||||
subject.vm_integration_services["entry"] = "value"
|
||||
subject.finalize!
|
||||
expect(subject.vm_integration_services["entry"]).to eq("value")
|
||||
end
|
||||
|
||||
it "does not accept non-Hash types" do
|
||||
subject.vm_integration_services = "value"
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result["Hyper-V"]).not_to be_empty
|
||||
end
|
||||
|
||||
it "accepts boolean values within Hash" do
|
||||
subject.vm_integration_services["custom"] = true
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result["Hyper-V"]).to be_empty
|
||||
end
|
||||
|
||||
it "does not accept non-boolean values within Hash" do
|
||||
subject.vm_integration_services["custom"] = "value"
|
||||
subject.finalize!
|
||||
result = subject.validate(machine)
|
||||
expect(result["Hyper-V"]).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue