Just a few additional tests for the new property "comment" of the host type.
Signed-off-by: Stefan Schulte <stefan.schu...@taunusstein.net> --- spec/unit/provider/host/parsed_spec.rb | 44 ++++++++++++++++++++++++++++++++ spec/unit/type/host_spec.rb | 2 +- 2 files changed, 45 insertions(+), 1 deletions(-) mode change 100755 => 100644 spec/unit/provider/host/parsed_spec.rb 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 d8ce291..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 -- 1.7.3.2 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-...@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.