2015-05-15 16:54:57 +00:00
|
|
|
require_relative "../../../base"
|
|
|
|
|
|
|
|
require "vagrant/util/template_renderer"
|
|
|
|
|
|
|
|
describe "templates/guests/debian/network_dhcp" do
|
|
|
|
let(:template) { "guests/debian/network_dhcp" }
|
|
|
|
|
|
|
|
it "renders the template" do
|
|
|
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
2016-06-06 16:34:45 +00:00
|
|
|
device: "eth1",
|
2015-05-15 16:54:57 +00:00
|
|
|
})
|
|
|
|
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
|
|
|
|
#VAGRANT-BEGIN
|
|
|
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
2016-06-06 16:34:45 +00:00
|
|
|
auto eth1
|
|
|
|
iface eth1 inet dhcp
|
2015-05-15 16:54:57 +00:00
|
|
|
post-up route del default dev $IFACE || true
|
|
|
|
#VAGRANT-END
|
|
|
|
EOH
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when use_dhcp_assigned_default_route is set" do
|
|
|
|
it "renders the template" do
|
|
|
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
2016-06-06 16:34:45 +00:00
|
|
|
device: "eth1",
|
2015-05-15 16:54:57 +00:00
|
|
|
use_dhcp_assigned_default_route: true,
|
|
|
|
})
|
|
|
|
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
|
|
|
|
#VAGRANT-BEGIN
|
|
|
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
2016-06-06 16:34:45 +00:00
|
|
|
auto eth1
|
|
|
|
iface eth1 inet dhcp
|
2015-05-15 16:54:57 +00:00
|
|
|
# We need to disable eth0, see GH-2648
|
2017-03-06 22:18:26 +00:00
|
|
|
post-up route del default dev $IFACE || true
|
2015-05-15 16:54:57 +00:00
|
|
|
post-up dhclient $IFACE
|
2017-03-06 22:18:26 +00:00
|
|
|
pre-down route add default dev $IFACE
|
2015-05-15 16:54:57 +00:00
|
|
|
#VAGRANT-END
|
|
|
|
EOH
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|