summaryrefslogtreecommitdiffstats
path: root/test/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-31 22:50:09 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-31 22:50:09 +0000
commit03357432210eecc5f370f812f473bc5d0a062d64 (patch)
tree255b176c9abe839d1d2d3e4919a7527a6f01d37c /test/puppet
parentba76eb2da506aee52b5bbbce842fa5ac361540a0 (diff)
downloadpuppet-03357432210eecc5f370f812f473bc5d0a062d64.tar.gz
puppet-03357432210eecc5f370f812f473bc5d0a062d64.tar.xz
puppet-03357432210eecc5f370f812f473bc5d0a062d64.zip
adding config file stuff, but not using it yet. I have decided to release the next version without them.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@738 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/puppet')
-rwxr-xr-xtest/puppet/conffiles.rb104
1 files changed, 104 insertions, 0 deletions
diff --git a/test/puppet/conffiles.rb b/test/puppet/conffiles.rb
new file mode 100755
index 000000000..f966322f7
--- /dev/null
+++ b/test/puppet/conffiles.rb
@@ -0,0 +1,104 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = ".."
+end
+
+require 'puppet'
+require 'puppet/config'
+require 'puppettest'
+require 'test/unit'
+
+class TestConfFiles < Test::Unit::TestCase
+ include TestPuppet
+
+ @@gooddata = [
+ {
+ "fun" => {
+ "a" => "b",
+ "c" => "d",
+ "e" => "f"
+ },
+ "yay" => {
+ "aa" => "bk",
+ "ca" => "dk",
+ "ea" => "fk"
+ },
+ "boo" => {
+ "eb" => "fb"
+ },
+ "rah" => {
+ "aa" => "this is a sentence",
+ "ca" => "dk",
+ "ea" => "fk"
+ },
+ },
+ {
+ "puppet" => {
+ "yay" => "rah"
+ },
+ "booh" => {
+ "okay" => "rah"
+ },
+ "back" => {
+ "okay" => "rah"
+ },
+ }
+ ]
+
+ def data2config(data)
+ str = ""
+
+ if data.include?("puppet")
+ # because we're modifying it
+ data = data.dup
+ str += "[puppet]\n"
+ data["puppet"].each { |var, value|
+ str += "%s %s\n" % [var, value]
+ }
+ data.delete("puppet")
+ end
+
+ data.each { |type, settings|
+ str += "[%s]\n" % type
+ settings.each { |var, value|
+ str += "%s %s\n" % [var, value]
+ }
+ }
+
+ return str
+ end
+
+ def sampledata
+ if block_given?
+ @@gooddata.each { |hash| yield hash }
+ else
+ return @@gooddata[0]
+ end
+ end
+
+ def test_readconfig
+ path = tempfile()
+
+ sampledata { |data|
+ # Write it out as a config file
+ File.open(path, "w") { |f| f.print data2config(data) }
+ config = nil
+ assert_nothing_raised {
+ config = Puppet::Config.new(path)
+ }
+
+ data.each { |section, hash|
+ hash.each { |var, value|
+ assert_equal(
+ data[section][var],
+ config[section][var],
+ "Got different values at %s/%s" % [section, var]
+ )
+ }
+ }
+ }
+ end
+end
+
+# $Id$