diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-08-04 00:36:47 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-08-04 00:36:47 +0000 |
| commit | 40e4d6fa02e801a26c2880840befa32718e55452 (patch) | |
| tree | 893496547abebfd805e4b28e4ba13f443c66e897 /test/util | |
| parent | 97cd057177f18a0e6694aab0e440f86e0bf08d42 (diff) | |
| download | puppet-40e4d6fa02e801a26c2880840befa32718e55452.tar.gz puppet-40e4d6fa02e801a26c2880840befa32718e55452.tar.xz puppet-40e4d6fa02e801a26c2880840befa32718e55452.zip | |
Fixing #735 -- gen_config now uses a single heading, matching the name of the process
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2743 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/util')
| -rwxr-xr-x | test/util/config.rb | 80 |
1 files changed, 57 insertions, 23 deletions
diff --git a/test/util/config.rb b/test/util/config.rb index 8e7215e8e..71343556f 100755 --- a/test/util/config.rb +++ b/test/util/config.rb @@ -16,6 +16,23 @@ class TestConfig < Test::Unit::TestCase @config = mkconfig end + def set_configs(config = nil) + config ||= @config + config.setdefaults("main", + :one => ["a", "one"], + :two => ["a", "two"], + :yay => ["/default/path", "boo"], + :mkusers => [true, "uh, yeah"], + :name => ["testing", "a"] + ) + + config.setdefaults("section1", + :attr => ["a", "one"], + :attrdir => ["/another/dir", "two"], + :attr3 => ["$attrdir/maybe", "boo"] + ) + end + def check_for_users count = Puppet::Type.type(:user).inject(0) { |c,o| c + 1 @@ -23,10 +40,11 @@ class TestConfig < Test::Unit::TestCase assert(count > 0, "Found no users") end - def check_to_transportable(config) + def test_to_transportable + set_configs trans = nil assert_nothing_raised("Could not convert to a transportable") { - trans = config.to_transportable + trans = @config.to_transportable } comp = nil @@ -34,17 +52,16 @@ class TestConfig < Test::Unit::TestCase comp = trans.to_type } - check_for_users() - assert_nothing_raised("Could not retrieve transported config") { comp.retrieve } end - def check_to_manifest(config) + def test_to_manifest + set_configs manifest = nil assert_nothing_raised("Could not convert to a manifest") { - manifest = config.to_manifest + manifest = @config.to_manifest } Puppet[:parseonly] = true @@ -61,32 +78,51 @@ class TestConfig < Test::Unit::TestCase assert_nothing_raised("Could not instantiate objects") { trans.to_type } - check_for_users() end - def check_to_comp(config) + def test_to_comp + set_configs comp = nil assert_nothing_raised("Could not convert to a component") { - comp = config.to_component + comp = @config.to_component } assert_nothing_raised("Could not retrieve component") { comp.retrieve } - - check_for_users() end - def check_to_config(config) - newc = config.dup + def test_to_config + set_configs + + newc = mkconfig + set_configs(newc) + + # Reset all of the values, so we know they're changing. + newc.each do |name, obj| + next if name == :name + newc[name] = true + end newfile = tempfile() - File.open(newfile, "w") { |f| f.print config.to_config } + File.open(newfile, "w") { |f| + @config.to_config.split("\n").each do |line| + # Uncomment the settings, so they actually take. + if line =~ / = / + f.puts line.sub(/^\s*#/, '') + else + f.puts line + end + end + } + assert_nothing_raised("Could not parse generated configuration") { newc.parse(newfile) } - assert_equal(config, newc, "Configurations are not equal") + @config.each do |name, object| + assert_equal(@config[name], newc[name], "Parameter %s is not the same" % name) + end end def mkconfig @@ -314,14 +350,6 @@ yay = /a/path assert_nothing_raised("Could not create transportable config") { @config.to_transportable } - - check_to_comp(@config) - Puppet::Type.allclear - check_to_manifest(@config) - Puppet::Type.allclear - check_to_config(@config) - Puppet::Type.allclear - check_to_transportable(@config) end def test_parse @@ -337,6 +365,12 @@ yay = /a/path :other => ["a", "b"], :name => ["puppet", "b"] # our default name ) + @config.setdefaults(:other, + :one => ["whatever", "a"], + :two => ["default", "y"], + :apple => ["a", "b"], + :shoe => ["puppet", "b"] # our default name + ) @config.handlearg("--cliparam", "changed") @config.expects(:parse_file).returns(result).times(2) |
