summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/type/interface.rb1
-rwxr-xr-xspec/unit/ral/types/interface.rb95
-rwxr-xr-xtest/ral/types/interface.rb39
3 files changed, 95 insertions, 40 deletions
diff --git a/lib/puppet/type/interface.rb b/lib/puppet/type/interface.rb
index 357adeea8..a077f55f3 100644
--- a/lib/puppet/type/interface.rb
+++ b/lib/puppet/type/interface.rb
@@ -57,4 +57,3 @@ Puppet::Type.newtype(:interface) do
defaultto { @resource.provider.file_path }
end
end
-
diff --git a/spec/unit/ral/types/interface.rb b/spec/unit/ral/types/interface.rb
new file mode 100755
index 000000000..2e0176152
--- /dev/null
+++ b/spec/unit/ral/types/interface.rb
@@ -0,0 +1,95 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+interface = Puppet::Type.type(:interface)
+
+describe interface do
+ before do
+ @class = Puppet::Type.type(:interface)
+
+ @provider_class = stub 'provider_class', :name => "fake", :suitable? => true, :supports_parameter? => true
+ @class.stubs(:defaultprovider).returns(@provider_class)
+ @class.stubs(:provider).returns(@provider_class)
+
+ @provider = stub 'provider', :class => @provider_class, :file_path => "/tmp/whatever", :clear => nil
+ @provider_class.stubs(:new).returns(@provider)
+ end
+
+ it "should have a name parameter" do
+ @class.attrtype(:name).should == :param
+ end
+
+ it "should have :name be its namevar" do
+ @class.namevar.should == :name
+ end
+
+ it "should have a :provider parameter" do
+ @class.attrtype(:provider).should == :param
+ end
+
+ it "should have an ensure property" do
+ @class.attrtype(:ensure).should == :property
+ end
+
+ it "should support :present as a value for :ensure" do
+ proc { @class.create(:name => "whev", :ensure => :present) }.should_not raise_error
+ end
+
+ it "should support :absent as a value for :ensure" do
+ proc { @class.create(:name => "whev", :ensure => :absent) }.should_not raise_error
+ end
+
+ it "should have an interface_type property" do
+ @class.attrtype(:interface_type).should == :property
+ end
+ it "should support :loopback as an interface_type value" do
+ proc { @class.create(:name => "whev", :interface_type => :loopback) }.should_not raise_error
+ end
+ it "should support :alias as an interface_type value" do
+ proc { @class.create(:name => "whev", :interface_type => :alias) }.should_not raise_error
+ end
+ it "should support :normal as an interface_type value" do
+ proc { @class.create(:name => "whev", :interface_type => :normal) }.should_not raise_error
+ end
+ it "should alias :dummy to the :loopback interface_type value" do
+ int = @class.create(:name => "whev", :interface_type => :dummy)
+ int.should(:interface_type).should == :loopback
+ end
+
+ it "should not support values other than :loopback, :alias, :normal, and :dummy in the interface_type" do
+ proc { @class.create(:name => "whev", :interface_type => :something) }.should raise_error(Puppet::Error)
+ end
+
+ it "should have an interface_desc parameter" do
+ @class.attrtype(:interface_desc).should == :param
+ end
+
+ it "should have an onboot property" do
+ @class.attrtype(:onboot).should == :property
+ end
+ it "should support :true as an onboot value" do
+ proc { @class.create(:name => "whev", :onboot => :true) }.should_not raise_error
+ end
+ it "should support :false as an onboot value" do
+ proc { @class.create(:name => "whev", :onboot => :false) }.should_not raise_error
+ end
+
+ it "should have an ifnum property" do
+ @class.attrtype(:ifnum).should == :property
+ end
+
+ it "should have a netmask property" do
+ @class.attrtype(:netmask).should == :property
+ end
+
+ it "should have an ifopts property" do
+ @class.attrtype(:ifopts).should == :property
+ end
+
+ it "should have a target parameter" do
+ @class.attrtype(:target).should == :param
+ end
+
+ after { @class.clear }
+end
diff --git a/test/ral/types/interface.rb b/test/ral/types/interface.rb
deleted file mode 100755
index babe133c3..000000000
--- a/test/ral/types/interface.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../lib/puppettest'
-
-require 'puppettest'
-require 'mocha'
-
-class TestInterfaceType < PuppetTest::TestCase
- confine "Could not find suitable interface provider" => Puppet::Type.type(:interface).suitableprovider.length > 0
-
- def setup
- super
- @type = Puppet::Type.type(:interface)
- end
-
- def test_prefetch
- interface = @type.create(:name => "127.0.0.1", :interface => "lo0", :check => :all)
-
- @type.suitableprovider.each do |provider|
- assert_nothing_raised("Could not prefetch interfaces from %s provider" % provider.name) do
- provider.prefetch("eth0" => interface)
- end
- end
- end
-
- def test_instances
- @type.suitableprovider.each do |provider|
- list = nil
- assert_nothing_raised("Could not get instance list from %s" % provider.name) do
- list = provider.instances
- end
- assert(list.length > 0, "Did not get any instances from %s" % provider.name)
- list.each do |interface|
- assert_instance_of(provider, interface, "%s provider returned something other than a provider instance" % provider.name)
- end
- end
- end
-end
-