chef-lctp/spec/coobooks/lctp-network_spec.rb

43 lines
1.3 KiB
Ruby

require_relative '../spec_helper'
describe 'lctp-network::default' do
let(:chef_run) do
ChefSpec::Runner.new do |node|
node.set["lctp_network"] = {
domain_servers: ["127.0.0.1"],
search_domains: ["lctp"],
interfaces: {
eth0: { },
eth1: {
static_ip: "10.0.0.1"
}
}
}
end.converge(described_recipe)
end
it "should include cookbooks" do
chef_run.should render_file("/etc/network/interfaces")
chef_run.should render_file("/etc/resolv.conf").
with_content("127.0.0.1").with_content("lctp")
eth0 = chef_run.find_resource(:network_interfaces, "eth0")
eth0.should_not == nil
eth0.bootproto.should == "dhcp"
eth1 = chef_run.find_resource(:network_interfaces, "eth1")
eth1.should_not == nil
eth1.bootproto.should == "static"
eth1.target.should == "10.0.0.1"
eth1.mask.should == "255.255.255.0" # default netmask
end
end
describe 'lctp-network::router' do
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
it "should setup NAT" do
chef_run.should render_file("/etc/network/if-pre-up.d/iptables-load")
chef_run.should render_file("/etc/network/if-post-down.d/iptables-save")
chef_run.should render_file("/etc/iptables.rules").with_content("eth0")
end
end