summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-13 18:24:34 -0600
committerLuke Kanies <luke@madstop.com>2009-02-13 18:24:34 -0600
commit3fbec120768d84d208b14f574dfe916e25cfdbef (patch)
tree865d59f4ea9cf3782db46ce1ae7fd54b95945035 /spec/unit/provider
parenta2270b4a4f093c6c4f171dcf0c0e05fe101dd979 (diff)
parent2561c8e252dcf66890513458750bb1329a03beec (diff)
downloadpuppet-3fbec120768d84d208b14f574dfe916e25cfdbef.tar.gz
puppet-3fbec120768d84d208b14f574dfe916e25cfdbef.tar.xz
puppet-3fbec120768d84d208b14f574dfe916e25cfdbef.zip
Merge branch '0.24.x'
Conflicts: lib/puppet/indirector/facts/facter.rb lib/puppet/provider/augeas/augeas.rb lib/puppet/util/filetype.rb spec/unit/indirector/facts/facter.rb spec/unit/provider/augeas/augeas.rb test/util/filetype.rb
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/augeas/augeas.rb30
-rwxr-xr-xspec/unit/provider/parsedfile.rb36
2 files changed, 56 insertions, 10 deletions
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 083448b4a..affc66676 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -285,32 +285,42 @@ describe provider_class do
@augeas.expects(:clear).with("/foo/Jar/Jar")
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
- end
+ end
+
- it "should handle insert commands" do
- command = [["insert", "/Jar/Jar"]]
+ it "should handle ins commands with before" do
+ command = [["ins", "Binks", "before /Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", true)
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
end
- it "should handle ins commands" do
- command = [["ins", "/Jar/Jar"]]
+ it "should handle ins commands with before" do
+ command = [["ins", "Binks", "after /Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
end
+ it "should handle ins with no context" do
+ command = [["ins", "Binks", "after /Jar/Jar"]]
+ context = "" # this is the default
+ @resource.expects(:[]).times(2).returns(command).then.returns(context)
+ @augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
+ @augeas.expects(:save).returns(true)
+ @provider.execute_changes.should == :executed
+ end
+
it "should handle multiple commands" do
- command = [["ins", "/Jar/Jar"], ["clear", "/Jar/Jar"]]
+ command = [["ins", "Binks", "after /Jar/Jar"], ["clear", "/Jar/Jar"]]
context = "/foo"
@resource.expects(:[]).times(2).returns(command).then.returns(context)
- @augeas.expects(:insert).with("/foo/Jar/Jar")
- @augeas.expects(:clear).with("/foo/Jar/Jar")
+ @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
+ @augeas.expects(:clear).with("/foo/Jar/Jar")
@augeas.expects(:save).returns(true)
@provider.execute_changes.should == :executed
end
diff --git a/spec/unit/provider/parsedfile.rb b/spec/unit/provider/parsedfile.rb
index 05e9de3ab..11a91c8d7 100755
--- a/spec/unit/provider/parsedfile.rb
+++ b/spec/unit/provider/parsedfile.rb
@@ -47,4 +47,40 @@ describe Puppet::Provider::ParsedFile do
@class.instances
end
end
+
+ describe "when flushing a file's records to disk" do
+ before do
+ # This way we start with some @records, like we would in real life.
+ @class.stubs(:retrieve).returns []
+ @class.default_target = "/foo/bar"
+ @class.initvars
+ @class.prefetch
+
+ @filetype = mock 'filetype'
+ Puppet::Util::FileType.filetype(:flat).expects(:new).with("/my/file").returns @filetype
+
+ @filetype.stubs(:write)
+ end
+
+ it "should back up the file being written" do
+ @filetype.expects(:backup)
+
+ @class.flush_target("/my/file")
+ end
+
+ it "should not back up the file more than once between calls to 'prefetch'" do
+ @filetype.expects(:backup).once
+
+ @class.flush_target("/my/file")
+ @class.flush_target("/my/file")
+ end
+
+ it "should back the file up again once the file has been reread" do
+ @filetype.expects(:backup).times(2)
+
+ @class.flush_target("/my/file")
+ @class.prefetch
+ @class.flush_target("/my/file")
+ end
+ end
end