Update config/vm with tests for disk config
This commit is contained in:
parent
d6df83103e
commit
93828508ec
|
@ -128,20 +128,27 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Merge defined disks
|
# Merge defined disks
|
||||||
other_disks = other.instance_variable_get(:@disks)
|
other_disks = other.instance_variable_get(:@disks)
|
||||||
new_disks = @disks.dup
|
new_disks = []
|
||||||
@disks.each do |d|
|
@disks.each do |p|
|
||||||
other_d = other_disks.find { |o| d.id == o.id }
|
other_p = other_disks.find { |o| p.id == o.id }
|
||||||
if other_d
|
if other_p
|
||||||
# There is an override. Take it.
|
# there is an override. take it.
|
||||||
other_d.config = d.config.merge(other_p.config)
|
other_p.config = p.config.merge(other_p.config)
|
||||||
|
#other_p.run ||= p.run
|
||||||
|
#next if !other_p.preserve_order
|
||||||
|
|
||||||
|
# we're preserving order, delete from other
|
||||||
|
p = other_p
|
||||||
|
other_disks.delete(other_p)
|
||||||
end
|
end
|
||||||
|
|
||||||
# There is an override, merge it into the
|
# there is an override, merge it into the
|
||||||
new_disks << d.dup
|
new_disks << p.dup
|
||||||
end
|
end
|
||||||
other_disks.each do |d|
|
other_disks.each do |p|
|
||||||
new_disks << d.dup
|
new_disks << p.dup
|
||||||
end
|
end
|
||||||
|
result.instance_variable_set(:@disks, new_disks)
|
||||||
|
|
||||||
# Merge the providers by prepending any configuration blocks we
|
# Merge the providers by prepending any configuration blocks we
|
||||||
# have for providers onto the new configuration.
|
# have for providers onto the new configuration.
|
||||||
|
@ -173,17 +180,17 @@ module VagrantPlugins
|
||||||
@provisioners.each do |p|
|
@provisioners.each do |p|
|
||||||
other_p = other_provs.find { |o| p.id == o.id }
|
other_p = other_provs.find { |o| p.id == o.id }
|
||||||
if other_p
|
if other_p
|
||||||
# There is an override. Take it.
|
# there is an override. take it.
|
||||||
other_p.config = p.config.merge(other_p.config)
|
other_p.config = p.config.merge(other_p.config)
|
||||||
other_p.run ||= p.run
|
other_p.run ||= p.run
|
||||||
next if !other_p.preserve_order
|
next if !other_p.preserve_order
|
||||||
|
|
||||||
# We're preserving order, delete from other
|
# we're preserving order, delete from other
|
||||||
p = other_p
|
p = other_p
|
||||||
other_provs.delete(other_p)
|
other_provs.delete(other_p)
|
||||||
end
|
end
|
||||||
|
|
||||||
# There is an override, merge it into the
|
# there is an override, merge it into the
|
||||||
new_provs << p.dup
|
new_provs << p.dup
|
||||||
end
|
end
|
||||||
other_provs.each do |p|
|
other_provs.each do |p|
|
||||||
|
|
|
@ -549,6 +549,44 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#disk" do
|
||||||
|
it "stores the disks" do
|
||||||
|
subject.disk("disk", size: 100)
|
||||||
|
subject.disk("disk", size: 1000, primary: false, name: "storage")
|
||||||
|
subject.finalize!
|
||||||
|
|
||||||
|
d = subject.disks
|
||||||
|
expect(d.length).to eql(2)
|
||||||
|
expect(d[0].size).to eql(100)
|
||||||
|
expect(d[1].size).to eql(1000)
|
||||||
|
expect(d[1].name).to eql("storage")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not merge duplicate disks" do
|
||||||
|
subject.disk("disk", size: 1000, primary: false, name: "storage")
|
||||||
|
subject.disk("disk", size: 1000, primary: false, name: "backup")
|
||||||
|
|
||||||
|
merged = subject.merge(subject)
|
||||||
|
merged_disks = merged.disks
|
||||||
|
|
||||||
|
expect(merged_disks.length).to eql(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "ignores non-overriding runs" do
|
||||||
|
subject.disk("disk", name: "foo")
|
||||||
|
|
||||||
|
other = described_class.new
|
||||||
|
other.disk("disk", name: "bar", primary: false)
|
||||||
|
|
||||||
|
merged = subject.merge(other)
|
||||||
|
merged_disks = merged.disks
|
||||||
|
|
||||||
|
expect(merged_disks.length).to eql(2)
|
||||||
|
expect(merged_disks[0].name).to eq("foo")
|
||||||
|
expect(merged_disks[1].name).to eq("bar")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#synced_folder(s)" do
|
describe "#synced_folder(s)" do
|
||||||
it "defaults to sharing the current directory" do
|
it "defaults to sharing the current directory" do
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
|
|
Loading…
Reference in New Issue