summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-31 14:37:03 -0600
committerLuke Kanies <luke@madstop.com>2007-12-31 14:37:03 -0600
commit33e319a8be8e35fbe4a9ecb7e3185453b8239a83 (patch)
tree15cb3788a9a3c783463e2cc129a7cf03c77498a0 /spec/unit/util
parent68cde4f1babe3ebf61ffe215c6328faf7818d40f (diff)
downloadpuppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.tar.gz
puppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.tar.xz
puppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.zip
Added builtin support for all Nagios resource types.
I use Naginator to parse and generate the files, with ParsedFile to handle record management and the like. Note that each resource type itself is just a call to a Factory method, since everything is just based on Naginator. Given that, all of the tests are in a single unit/ral/types/nagios.rb file, since I used a factory to generate them, too. This is probably either unnecessary or insufficient, but it's as far as I'm willing to go in testing them, and it did actually catch a few bugs.
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-xspec/unit/util/nagios_maker.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/util/nagios_maker.rb b/spec/unit/util/nagios_maker.rb
index 145f8633a..0454b6503 100755
--- a/spec/unit/util/nagios_maker.rb
+++ b/spec/unit/util/nagios_maker.rb
@@ -63,6 +63,30 @@ describe Puppet::Util::NagiosMaker do
@module.create_nagios_type(:test)
end
+ it "should skip parameters that start with integers" do
+ type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil
+
+ @nagtype.stubs(:parameters).returns(["2dcoords".to_sym, :other])
+
+ type.expects(:newproperty).with(:other)
+ type.expects(:newproperty).with(:target)
+
+ Puppet::Type.expects(:newtype).with(:nagios_test).returns(type)
+ @module.create_nagios_type(:test)
+ end
+
+ it "should deduplicate the parameter list" do
+ type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil
+
+ @nagtype.stubs(:parameters).returns([:one, :one])
+
+ type.expects(:newproperty).with(:one)
+ type.expects(:newproperty).with(:target)
+
+ Puppet::Type.expects(:newtype).with(:nagios_test).returns(type)
+ @module.create_nagios_type(:test)
+ end
+
it "should create a target property" do
type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil