diff options
| author | Luke Kanies <luke@madstop.com> | 2007-12-31 14:37:03 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-12-31 14:37:03 -0600 |
| commit | 33e319a8be8e35fbe4a9ecb7e3185453b8239a83 (patch) | |
| tree | 15cb3788a9a3c783463e2cc129a7cf03c77498a0 /spec/unit/ral | |
| parent | 68cde4f1babe3ebf61ffe215c6328faf7818d40f (diff) | |
| download | puppet-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/ral')
| -rwxr-xr-x | spec/unit/ral/types/nagios.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/unit/ral/types/nagios.rb b/spec/unit/ral/types/nagios.rb new file mode 100755 index 000000000..8aca7d401 --- /dev/null +++ b/spec/unit/ral/types/nagios.rb @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +require 'puppet/external/nagios' + +Nagios::Base.eachtype do |name, nagios_type| + puppet_type = Puppet::Type.type("nagios_" + name.to_s) + + describe puppet_type do + it "should be defined as a Puppet resource type" do + puppet_type.should_not be_nil + end + + it "should have documentation" do + puppet_type.instance_variable_get("@doc").should_not == "" + end + + it "should have %s as its namevar" % nagios_type.namevar do + puppet_type.namevar.should == nagios_type.namevar + end + + it "should have documentation for its %s parameter" % nagios_type.namevar do + puppet_type.attrclass(nagios_type.namevar).instance_variable_get("@doc").should_not be_nil + end + + it "should have an ensure property" do + puppet_type.should be_validproperty(:ensure) + end + + it "should have a target property" do + puppet_type.should be_validproperty(:target) + end + + it "should have documentation for its target property" do + puppet_type.attrclass(:target).instance_variable_get("@doc").should_not be_nil + end + + nagios_type.parameters.reject { |param| param == nagios_type.namevar or param.to_s =~ /^[0-9]/ }.each do |param| + it "should have a %s property" % param do + puppet_type.should be_validproperty(param) + end + + it "should have documentation for its %s property" % param do + puppet_type.attrclass(param).instance_variable_get("@doc").should_not be_nil + end + end + + nagios_type.parameters.find_all { |param| param.to_s =~ /^[0-9]/ }.each do |param| + it "should have not have a %s property" % param do + puppet_type.should_not be_validproperty(:param) + end + end + end +end |
