summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/interface
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-03 15:13:09 -0500
committerLuke Kanies <luke@madstop.com>2008-07-03 15:13:09 -0500
commit04ecb742f46cf8e48337c854a5ff2377caf60db1 (patch)
tree31b0e613d272fd0b2572116286ae2f69221546e2 /spec/unit/provider/interface
parenta87885a4be181206d2f2c1d6225598c67e315717 (diff)
Doing what I can to fix #1128, but just in preparation for removing 'interface'.
This type needs to be started again from scratch, and I'm not going to do so for 0.24.5. In particular, the model for red hat and sunos need to match -- they should both use the device name as the actual name. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/provider/interface')
-rwxr-xr-xspec/unit/provider/interface/redhat.rb45
1 files changed, 24 insertions, 21 deletions
diff --git a/spec/unit/provider/interface/redhat.rb b/spec/unit/provider/interface/redhat.rb
index 515c9f775..70830aab5 100755
--- a/spec/unit/provider/interface/redhat.rb
+++ b/spec/unit/provider/interface/redhat.rb
@@ -64,35 +64,38 @@ describe provider_class, "when determining the file path" do
end
end
-describe provider_class, "when returning instances" do
- it "should consider each file in the network-scripts directory an interface instance" do
- Dir.expects(:glob).with("/etc/sysconfig/network-scripts/ifcfg-*").returns(%w{one two})
- one = {:name => "one"}
- two = {:name => "two"}
- Puppet::Type::Interface::ProviderRedhat.expects(:parse).with("one").returns(one)
- Puppet::Type::Interface::ProviderRedhat.expects(:parse).with("two").returns(two)
- Puppet::Type::Interface::ProviderRedhat.expects(:new).with(one).returns(:one)
- Puppet::Type::Interface::ProviderRedhat.expects(:new).with(two).returns(:two)
- Puppet::Type::Interface::ProviderRedhat.instances.should == [:one, :two]
+describe provider_class, "when parsing" do
+ before do
+ @provider = Puppet::Type::Interface::ProviderRedhat.new
+ end
+
+ it "should return nil if the file name does not include an interface" do
+ Puppet::Type::Interface::ProviderRedhat.parse("/my/file").should be_nil
end
-end
-describe provider_class, "when parsing" do
it "should return an unmodified provider if the file does not exist" do
- FileTest.expects(:exist?).with("/my/file").returns(false)
+ FileTest.expects(:exist?).with("/my/ifcfg-eth0").returns(false)
provider = mock 'provider'
Puppet::Type::Interface::ProviderRedhat.expects(:new).returns(provider)
- Puppet::Type::Interface::ProviderRedhat.parse("/my/file").should equal(provider)
+ Puppet::Type::Interface::ProviderRedhat.parse("/my/ifcfg-eth0").should equal(provider)
end
it "should set each attribute in the file on the provider" do
- FileTest.expects(:exist?).with("/my/file").returns(true)
- File.expects(:readlines).with("/my/file").returns(%w{one=two three=four})
- provider = mock 'provider'
- Puppet::Type::Interface::ProviderRedhat.expects(:new).returns(provider)
- provider.expects(:one=).with('two')
- provider.expects(:three=).with('four')
- Puppet::Type::Interface::ProviderRedhat.parse("/my/file").should equal(provider)
+ FileTest.expects(:exist?).with("/my/ifcfg-eth0").returns(true)
+ File.expects(:readlines).with("/my/ifcfg-eth0").returns(%w{DEVICE=foo ONBOOT=yes})
+ Puppet::Type::Interface::ProviderRedhat.expects(:new).returns(@provider)
+ @provider.expects(:device=).with('foo')
+ @provider.expects(:onboot=).with('yes')
+ Puppet::Type::Interface::ProviderRedhat.parse("/my/ifcfg-eth0").should equal(@provider)
+ end
+
+ it "should not try to assign parameters that the provider does not support" do
+ Puppet::Type::Interface::ProviderRedhat.expects(:new).returns @provider
+
+ file = "/my/file/ifcfg-eth0"
+ FileTest.stubs(:exist?).returns true
+ File.expects(:readlines).with(file).returns %w{BOOTPROTO=foo\n DEVICE=eth0\n}
+ lambda { Puppet::Type::Interface::ProviderRedhat.parse(file) }.should_not raise_error
end
end