diff options
-rwxr-xr-x | lib/puppet/server/pelement.rb | 17 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/checksum.rb | 3 | ||||
-rw-r--r-- | test/server/pelement.rb | 67 |
3 files changed, 60 insertions, 27 deletions
diff --git a/lib/puppet/server/pelement.rb b/lib/puppet/server/pelement.rb index 660954942..7c4ee7fb3 100755 --- a/lib/puppet/server/pelement.rb +++ b/lib/puppet/server/pelement.rb @@ -76,7 +76,22 @@ class Server::PElementServer end end - def list(type, name, client = nil, clientip = nil) + def list(type, ignore = [], base = nil, client = nil, clientip = nil) + @local = true unless client + typeklass = nil + unless typeklass = Puppet.type(type) + raise Puppet::Error, "Puppet type %s is unsupported" % type + end + + bucket = TransBucket.new + bucket.type = typeklass.name + + typeklass.list.each do |obj| + object = TransObject.new(obj.name, typeklass.name) + bucket << object + end + + bucket end private diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb index 54ab3d860..c00fd7f7f 100755 --- a/lib/puppet/type/pfile/checksum.rb +++ b/lib/puppet/type/pfile/checksum.rb @@ -288,8 +288,7 @@ module Puppet #@parent.debug "@is: %s; @should: %s" % [@is,@should] result = true else - @parent.debug "Creating checksum %s of type %s" % - [@is,@checktypes[0]] + @parent.debug "Creating checksum %s" % @is result = false end state[@checktypes[0]] = @is diff --git a/test/server/pelement.rb b/test/server/pelement.rb index 40d5f7ea1..a6970e049 100644 --- a/test/server/pelement.rb +++ b/test/server/pelement.rb @@ -14,6 +14,29 @@ require 'cgi' class TestPElementServer < Test::Unit::TestCase include ServerTest + def verify_described(type, described) + type.clear + described.each do |name, trans| + obj = nil + assert_nothing_raised do + obj = trans.to_type + end + + assert(obj, "Could not create object") + assert_nothing_raised do + obj.retrieve + end + + assert(obj.insync?, "Described %s[%s] is not in sync" % + [trans.type, name]) + + if trans.type == :package + assert_equal(Puppet::Type.type(:package).default, obj[:type]) + end + end + type.clear + end + def test_describe_file # Make a file to describe file = tempfile() @@ -168,9 +191,27 @@ class TestPElementServer < Test::Unit::TestCase Puppet.warning "%s does not respond to :list" % type.name next end - #next unless type.name == :file + #next unless type.name == :port Puppet.info "Describing each %s" % type.name + # First do a listing from the server + bucket = nil + assert_nothing_raised { + bucket = server.list(type.name) + } + + #type.clear + + count = 0 + described = {} + bucket.each do |obj| + assert_instance_of(Puppet::TransObject, obj) + break if count > 5 + described[obj.name] = server.describe(obj.type, obj.name) + count += 1 + end + + verify_described(type, described) count = 0 described = {} @@ -186,34 +227,12 @@ class TestPElementServer < Test::Unit::TestCase count += 1 end - # We have to clear, because the server has its own object - type.clear - if described.empty? Puppet.notice "Got no example objects for %s" % type.name end # We separate these, in case the list operation creates objects - described.each do |name, trans| - obj = nil - assert_nothing_raised do - obj = trans.to_type - end - - assert(obj, "Could not create object") - assert_nothing_raised do - obj.retrieve - end - - assert(obj.insync?, "Described %s[%s] is not in sync" % - [type.name, name]) - - if type.name == :package - assert_equal(Puppet::Type.type(:package).default, obj[:type]) - end - end - - type.clear + verify_described(type, described) end end end |