[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Nick Lewis nick at puppetlabs.com
Tue May 10 08:01:52 UTC 2011


The following commit has been merged in the experimental branch:
commit 2052f3611fd18cb93a43f4cfb547c9c9205a8952
Author: Stefan Schulte <stefan.schulte at taunusstein.net>
Date:   Wed Nov 17 23:28:56 2010 +0100

    (#5274) New tests for new hosttype/parsedprovider
    
    Just a few additional tests for the new property "comment" of the
    host type.

diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb
old mode 100755
new mode 100644
index 08254e6..239e3bd
--- a/spec/unit/provider/host/parsed_spec.rb
+++ b/spec/unit/provider/host/parsed_spec.rb
@@ -59,6 +59,10 @@ describe provider_class do
       @provider.parse_line("::1     localhost")[:name].should == "localhost"
     end
 
+    it "should set an empty comment" do
+      @provider.parse_line("::1     localhost")[:comment].should == ""
+    end
+
   end
 
   describe "when parsing a line with ip, hostname and comment" do
@@ -74,6 +78,10 @@ describe provider_class do
       @provider.parse_line(@testline)[:name].should == "localhost"
     end
 
+    it "should parse the comment after the first '#' character" do
+      @provider.parse_line(@testline)[:comment].should == 'A comment with a #-char'
+    end
+
   end
 
   describe "when parsing a line with ip, hostname and aliases" do
@@ -109,6 +117,10 @@ describe provider_class do
       @provider.parse_line(@testline)[:host_aliases].should == ['alias1' ,'alias2', 'alias3']
     end
 
+    it "should parse the comment after the first '#' character" do
+      @provider.parse_line(@testline)[:comment].should == 'A comment with a #-char'
+    end
+
   end
 
   describe "when operating on /etc/hosts like files" do
@@ -147,6 +159,38 @@ describe provider_class do
       genhost(host).should == "192.0.0.1\thost\ta1\ta2\ta3\ta4\n"
     end
 
+    it "should be able to generate a simple hostfile entry with comments" do
+      host = mkhost(
+        :name    => 'localhost',
+        :ip      => '127.0.0.1',
+        :comment => 'Bazinga!',
+        :ensure  => :present
+      )
+      genhost(host).should == "127.0.0.1\tlocalhost\t# Bazinga!\n"
+    end
+
+    it "should be able to generate an entry with one alias and a comment" do
+      host = mkhost(
+        :name   => 'localhost.localdomain',
+        :ip     => '127.0.0.1',
+        :host_aliases => ['localhost'],
+        :comment => 'Bazinga!',
+        :ensure => :present
+      )
+      genhost(host).should == "127.0.0.1\tlocalhost.localdomain\tlocalhost\t# Bazinga!\n"
+    end
+
+    it "should be able to generate an entry with more than one alias and a comment" do
+      host = mkhost(
+        :name         => 'host',
+        :ip           => '192.0.0.1',
+        :host_aliases => [ 'a1','a2','a3','a4' ],
+        :comment      => 'Bazinga!',
+        :ensure       => :present
+      )
+      genhost(host).should == "192.0.0.1\thost\ta1\ta2\ta3\ta4\t# Bazinga!\n"
+    end
+
   end
 
 end
diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb
index 43846b2..12ae2af 100755
--- a/spec/unit/type/host_spec.rb
+++ b/spec/unit/type/host_spec.rb
@@ -21,7 +21,7 @@ describe Puppet::Type.type(:host) do
       end
     end
 
-    [:ip, :target, :host_aliases, :ensure].each do |property|
+    [:ip, :target, :host_aliases, :comment, :ensure].each do |property|
       it "should have a #{property} property" do
         @class.attrtype(property).should == :property
       end
@@ -61,7 +61,6 @@ describe Puppet::Type.type(:host) do
     end
 
     it "should not accept malformed IPv4 addresses like 192.168.0.300" do
-      pending
       proc { @class.new(:name => "foo", :ip => '192.168.0.300') }.should raise_error
     end
 
@@ -78,7 +77,6 @@ describe Puppet::Type.type(:host) do
     end
 
     it "should not accept empty host_aliases" do
-      pending
       proc { @class.new(:name => "foo", :host_aliases => ['alias1','']) }.should raise_error
     end
   end
diff --git a/test/data/providers/host/parsed/valid_hosts b/test/data/providers/host/parsed/valid_hosts
index de5caf7..2463629 100644
--- a/test/data/providers/host/parsed/valid_hosts
+++ b/test/data/providers/host/parsed/valid_hosts
@@ -12,3 +12,8 @@
 # Ok its time to test aliases
 2001:252:0:1::2008:8 ipv6host alias1
 192.168.0.1 ipv4host alias2 alias3
+
+# Testing inlinecomments now
+192.168.0.2 host3 # This is host3
+192.168.0.3 host4 alias10 # This is host4
+192.168.0.4 host5   alias11             alias12      #     This is host5

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list