diff options
author | Paul Lathrop <paul@tertiusfamily.net> | 2008-03-25 14:09:15 -0700 |
---|---|---|
committer | Paul Lathrop <paul@tertiusfamily.net> | 2008-03-25 14:09:15 -0700 |
commit | 9cf7150549caf5d21a2a22f30d92cd5a73d00a40 (patch) | |
tree | f031122131988271a97d0d06b996d287c4232622 /spec | |
parent | e67e6b1f80c7e0d84bf1c77d179de28496d7a96c (diff) | |
download | puppet-9cf7150549caf5d21a2a22f30d92cd5a73d00a40.tar.gz puppet-9cf7150549caf5d21a2a22f30d92cd5a73d00a40.tar.xz puppet-9cf7150549caf5d21a2a22f30d92cd5a73d00a40.zip |
Added some more tests for loadedfile, based off the old unit tests.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/util/loadedfile.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/spec/unit/util/loadedfile.rb b/spec/unit/util/loadedfile.rb index 89c7547e0..b57475f96 100644 --- a/spec/unit/util/loadedfile.rb +++ b/spec/unit/util/loadedfile.rb @@ -9,11 +9,13 @@ describe Puppet::Util::LoadedFile do before(:all) do # First, save and adjust the timeout so tests don't take forever. @saved_filetimeout = Puppet[:filetimeout] - Puppet[:filetimeout] = 1 + Puppet[:filetimeout] = 5 end before(:each) do @f = Tempfile.new('loadedfile_test') + @f.puts "yayness" + @f.flush @loaded = Puppet::Util::LoadedFile.new(@f.path) end @@ -23,12 +25,31 @@ describe Puppet::Util::LoadedFile do end it "should recognize when the file has changed" do - @f.puts "Hello" + @f.puts "booness" @f.flush sleep(Puppet[:filetimeout]) @loaded.changed?.should be_an_instance_of(Time) end + it "should not catch a change until the timeout has elapsed" do + @f.puts "yay" + @f.flush + @loaded.changed?.should be(false) + sleep(Puppet[:filetimeout]) + @loaded.changed?.should_not be(false) + end + + it "should consider a file changed when that file is missing" do + @f.close! + sleep(Puppet[:filetimeout]) + @loaded.changed?.should_not be(false) + end + + it "should disable checking if Puppet[:filetimeout] is negative" do + Puppet[:filetimeout] = -1 + @loaded.changed?.should_not be(false) + end + after(:each) do @f.close end |