Right now validation seems to be done against zero byte generated temp
files. We need to close the file before executing validation against it.
tmpfile = Tempfile.new("validate_cmd")
begin
tmpfile.write(content)
+ tmpfile.close
if Puppet::Util::Execution.respond_to?('execute')
Puppet::Util::Execution.execute("#{checkscript} #{tmpfile.path}")
else
end
end
end
+
+ it "can positively validate file content" do
+ expect { subject.call ["non-empty", "/usr/bin/test -s"] }.to_not raise_error
+ end
+
+ it "can negatively validate file content" do
+ expect { subject.call ["", "/usr/bin/test -s"] }.to raise_error Puppet::ParseError, /failed to validate.*test -s/
+ end
end