diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-27 23:20:25 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-04-27 23:20:25 +0000 |
commit | 94bd3b28284f92583d6c49165d0dff1560e888ff (patch) | |
tree | ab29d724ab990d20a5c6cadcf019e05953909e66 | |
parent | 96eed993c3079cb5aa785a8f10b0d8f317e00193 (diff) | |
download | puppet-94bd3b28284f92583d6c49165d0dff1560e888ff.tar.gz puppet-94bd3b28284f92583d6c49165d0dff1560e888ff.tar.xz puppet-94bd3b28284f92583d6c49165d0dff1560e888ff.zip |
Apparently I messed up providers a bit; binaries were not having their full paths returned, which made most providers suddenly unsuitable. This fixes that, and adds tests to verify behaviour.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2426 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/provider.rb | 2 | ||||
-rwxr-xr-x | test/ral/manager/provider.rb | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb index d2d8ca1f7..a9c6c09eb 100644 --- a/lib/puppet/provider.rb +++ b/lib/puppet/provider.rb @@ -38,6 +38,7 @@ class Puppet::Provider # Define commands that are not optional. def self.commands(hash) optional_commands(hash) do |name, path| + Puppet.info "%s => %s" % [name, path] confine :exists => path end end @@ -163,6 +164,7 @@ class Puppet::Provider # Try to find the full path (or verify already-full paths); otherwise # store that the command is missing so we know it's defined but absent. if tmp = binary(path) + path = tmp @commands[name] = path else @commands[name] = :missing diff --git a/test/ral/manager/provider.rb b/test/ral/manager/provider.rb index c74293106..cafb84deb 100755 --- a/test/ral/manager/provider.rb +++ b/test/ral/manager/provider.rb @@ -50,6 +50,35 @@ class TestTypeProviders < Test::Unit::TestCase "Providify did not reorder parameters") end + def test_commands + type = Puppet::Type.newtype(:commands) {} + + cleanup { Puppet::Type.rmtype(:commands) } + + echo = %x{which echo}.chomp + {:echo => echo, :echo => "echo", :missing => "nosuchcommand", :missing => "/path/to/nosuchcommand"}.each do |name, command| + # Define a provider with mandatory commands + provider = type.provide(:testing) {} + + assert_nothing_raised("Could not define command %s with argument %s for provider" % [name, command]) do + provider.commands(name => command) + end + + case name + when :echo: + assert_equal(echo, provider.command(:echo), "Did not get correct path for echo") + assert(provider.suitable?, "Provider was not considered suitable with 'echo'") + when :missing: + assert_nil(provider.command(:missing), "Somehow got a response for missing commands") + assert(! provider.suitable?, "Provider was considered suitable with missing command") + else + raise "Invalid name %s" % name + end + + type.unprovide(:testing) + end + end + # Make sure optional commands get looked up but don't affect suitability. def test_optional_commands type = Puppet::Type.newtype(:optional_commands) {} |