[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:19 UTC 2009


The following commit has been merged in the master branch:
commit 2ebd34ecca413393b2619f8400d2046fa2ca6d9b
Author: Sean E. Millichamp <sean at bruenor.org>
Date:   Tue Oct 7 11:13:03 2008 -0400

    Rewrote seboolean unit tests to provide better coverage

diff --git a/spec/unit/provider/selboolean.rb b/spec/unit/provider/selboolean.rb
new file mode 100644
index 0000000..8fd97a6
--- /dev/null
+++ b/spec/unit/provider/selboolean.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+provider_class = Puppet::Type.type(:selboolean).provider(:getsetsebool)
+
+describe provider_class do
+    before :each do
+        @resource = stub("resource", :name => "foo")
+        @resource.stubs(:[]).returns "foo"
+        @provider = provider_class.new(@resource)
+    end
+
+    it "should return :on when getsebool returns on" do
+        @resource.stubs(:[]).returns "foo"
+        @provider.expects(:getsebool).with("foo").returns "foo --> on\n"
+        @provider.value.should == :on
+    end
+
+    it "should return :off when getsebool returns on" do
+        @resource.stubs(:[]).returns "foo"
+        @provider.expects(:getsebool).with("foo").returns "foo --> off\n"
+        @provider.value.should == :off
+    end
+
+    it "should call execpipe when updating boolean setting" do
+        @provider.expects(:execpipe).with("/usr/sbin/setsebool  foo off")
+        @provider.value = :off
+    end
+     
+    it "should call execpipe with -P when updating persistent boolean setting" do
+        @resource.stubs(:[]).returns "foo"
+        @resource.stubs(:[]).with(:persistent).returns :true
+        @provider.expects(:execpipe).with("/usr/sbin/setsebool -P foo off")
+        @provider.value = :off
+    end
+
+end
diff --git a/spec/unit/type/selboolean.rb b/spec/unit/type/selboolean.rb
new file mode 100644
index 0000000..80d6d64
--- /dev/null
+++ b/spec/unit/type/selboolean.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+describe Puppet::Type.type(:selboolean), "when validating attributes" do
+    [:name, :persistent].each do |param|
+        it "should have a #{param} parameter" do
+            Puppet::Type.type(:selboolean).attrtype(param).should == :param
+        end
+    end
+
+    it "should have a value property" do
+            Puppet::Type.type(:selboolean).attrtype(:value).should == :property
+    end
+end
+
+describe Puppet::Type.type(:selboolean), "when validating values" do
+    before do
+        @provider = stub 'provider', :class => Puppet::Type.type(:selboolean).defaultprovider, :clear => nil
+        Puppet::Type.type(:selboolean).defaultprovider.expects(:new).returns(@provider)
+    end
+
+    it "should support :on as a value to :value" do
+        Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on)
+    end
+
+    it "should support :off as a value to :value" do
+        Puppet::Type.type(:selboolean).create(:name => "yay", :value => :off)
+    end
+
+    it "should support :true as a value to :persistent" do
+        Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :true)
+    end
+
+    it "should support :false as a value to :persistent" do
+        Puppet::Type.type(:selboolean).create(:name => "yay", :value => :on, :persistent => :false)
+    end
+
+    after { Puppet::Type.type(:selboolean).clear }
+end
+

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list