diff options
| author | Luke Kanies <luke@madstop.com> | 2008-01-02 14:32:54 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-01-02 14:32:54 -0600 |
| commit | b7b11bd4858a4d6dd0661aa7c546d03b4a85ca7d (patch) | |
| tree | 7fa0a67b87d9ce19a51a468c0fe79c33e9ccbcdb | |
| parent | b1f13af734cc75d1b8c73f06d0619b99c65978c0 (diff) | |
Fixing a couple of failing tests
| -rwxr-xr-x | lib/puppet/type/schedule.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/util/nagios_maker.rb | 5 | ||||
| -rwxr-xr-x | spec/unit/util/nagios_maker.rb | 16 |
3 files changed, 14 insertions, 11 deletions
diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index b8479e01d..c494c5d94 100755 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -241,7 +241,9 @@ module Puppet :daily => :day, :monthly => :month, :weekly => proc do |prev, now| - prev.strftime("%U") != now.strftime("%U") + # Run the resource if the previous day was after this weekday (e.g., prev is wed, current is tue) + # or if it's been more than a week since we ran + prev.wday > now.wday or (now - prev) > (24 * 3600 * 7) end } diff --git a/lib/puppet/util/nagios_maker.rb b/lib/puppet/util/nagios_maker.rb index 88402838f..a7aae4e70 100644 --- a/lib/puppet/util/nagios_maker.rb +++ b/lib/puppet/util/nagios_maker.rb @@ -40,14 +40,15 @@ module Puppet::Util::NagiosMaker end end - provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => "/etc/nagios/#{full_name.to_s}.cfg") {} + target = "/etc/nagios/#{full_name.to_s}.cfg" + provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => target) {} type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the model developed in Naginator_, and all of the Nagios types are generated using the same code and the same library. This type generates Nagios configuration statements in Nagios-parseable configuration - files. By default, the statements will be added to ``#{provider.default_target}``, but + files. By default, the statements will be added to ``#{target}``, but you can send them to a different file by setting their ``target`` attribute. .. _naginator: http://reductivelabs.com/trac/naginator diff --git a/spec/unit/util/nagios_maker.rb b/spec/unit/util/nagios_maker.rb index 0454b6503..b75439400 100755 --- a/spec/unit/util/nagios_maker.rb +++ b/spec/unit/util/nagios_maker.rb @@ -26,14 +26,14 @@ describe Puppet::Util::NagiosMaker do end it "should create a new RAL type with the provided name prefixed with 'nagios_'" do - type = stub 'type', :newparam => nil, :newproperty => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newparam => nil, :newproperty => nil, :ensurable => nil, :provide => nil, :desc => nil Puppet::Type.expects(:newtype).with(:nagios_test).returns(type) @module.create_nagios_type(:test) end it "should mark the created type as ensurable" do - type = stub 'type', :newparam => nil, :newproperty => nil, :provide => nil + type = stub 'type', :newparam => nil, :newproperty => nil, :provide => nil, :desc => nil type.expects(:ensurable) @@ -42,7 +42,7 @@ describe Puppet::Util::NagiosMaker do end it "should create a namevar parameter for the nagios type's name parameter" do - type = stub 'type', :newproperty => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newproperty => nil, :ensurable => nil, :provide => nil, :desc => nil type.expects(:newparam).with(:name, :namevar => true) @@ -51,7 +51,7 @@ describe Puppet::Util::NagiosMaker do end it "should create a property for all non-namevar parameters" do - type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil, :desc => nil @nagtype.stubs(:parameters).returns([:one, :two]) @@ -64,7 +64,7 @@ describe Puppet::Util::NagiosMaker do end it "should skip parameters that start with integers" do - type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil, :desc => nil @nagtype.stubs(:parameters).returns(["2dcoords".to_sym, :other]) @@ -76,7 +76,7 @@ describe Puppet::Util::NagiosMaker do end it "should deduplicate the parameter list" do - type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil, :desc => nil @nagtype.stubs(:parameters).returns([:one, :one]) @@ -88,7 +88,7 @@ describe Puppet::Util::NagiosMaker do end it "should create a target property" do - type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil + type = stub 'type', :newparam => nil, :ensurable => nil, :provide => nil, :desc => nil type.expects(:newproperty).with(:target) @@ -104,7 +104,7 @@ describe Puppet::Util::NagiosMaker, " when creating the naginator provider" do @nagtype = stub 'nagios type', :parameters => [], :namevar => :name Nagios::Base.stubs(:type).with(:test).returns(@nagtype) - @type = stub 'type', :newparam => nil, :ensurable => nil, :newproperty => nil + @type = stub 'type', :newparam => nil, :ensurable => nil, :newproperty => nil, :desc => nil Puppet::Type.stubs(:newtype).with(:nagios_test).returns(@type) end |
