I'm going to write an rspec test for this, but I've never done it before and
am pretty intimidated by the syntax.  Ideally, I'd like to write a test that
looks at the two modified methods (get_exec_preamble and single_report) and
will test if puppet fails properly if @macosx_version_major is < '10.4'.
 I'm not sure if I should test the syntax for the command_vector and
dscl_plist variables or leave them be.  Either way, I'm pretty stumped as to
how to begin.  There is a test in spec/unit/provider/nameservice/ that I
could piggy-back into, but my tinkering hasn't proven fruitful.

Any pointers for a relative newbie to tests/patches would be appreciated!  I
figure this is a very simple patch and a good place to start with testing.

-Gary

On Sat, Feb 26, 2011 at 7:30 PM, Gary Larizza <[email protected]> wrote:

> This commit removes a case statement in the get_exec_pramble and
> single_report methods.  In its place is an if statement that will cause
> Puppet to fail if its being run on an OS X system with a version < 10.4.
>  This if-statement will also allow Puppet to run in 10.7.
>
> Signed-off-by: Gary Larizza <[email protected]>
> ---
>  .../provider/nameservice/directoryservice.rb       |   19
> +++++++++++--------
>  1 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/lib/puppet/provider/nameservice/directoryservice.rb
> b/lib/puppet/provider/nameservice/directoryservice.rb
> index 2e34809..d40eb9b 100644
> --- a/lib/puppet/provider/nameservice/directoryservice.rb
> +++ b/lib/puppet/provider/nameservice/directoryservice.rb
> @@ -235,11 +235,12 @@ class DirectoryService <
> Puppet::Provider::NameService
>     # have a lot of choice. Ultimately this should all be done using Ruby
>     # to access the DirectoryService APIs directly, but that's simply not
>     # feasible for a while yet.
> -    case self.get_macosx_version_major
> -    when "10.4"
> -      dscl_plist = self.parse_dscl_url_data(dscl_output)
> -    when "10.5", "10.6"
> +    if self.get_macosx_version_major > "10.4"
>       dscl_plist = self.parse_dscl_plist_data(dscl_output)
> +    elsif self.get_macosx_version_major == "10.4"
> +      dscl_plist = self.parse_dscl_url_data(dscl_output)
> +    else
> +      fail("Puppet does not support OS X versions < 10.4")
>     end
>
>     self.generate_attribute_hash(dscl_plist, *type_properties)
> @@ -257,12 +258,14 @@ class DirectoryService <
> Puppet::Provider::NameService
>     # different format for the -url output with objects with spaces in
>     # their values. *sigh*. Use -url for 10.4 in the hope this can be
>     # deprecated one day, and use -plist for 10.5 and higher.
> -    case self.get_macosx_version_major
> -    when "10.4"
> -      command_vector = [ command(:dscl), "-url", "." ]
> -    when "10.5", "10.6"
> +    if self.get_macosx_version_major > "10.4"
>       command_vector = [ command(:dscl), "-plist", "." ]
> +    elsif self.get_macosx_version_major == "10.4"
> +      command_vector = [ command(:dscl), "-url", "." ]
> +    else
> +      fail("Puppet does not support OS X versions < 10.4")
>     end
> +
>     # JJM: The actual action to perform.  See "man dscl"
>     #      Common actiosn: -create, -delete, -merge, -append, -passwd
>     command_vector << ds_action
> --
> 1.7.2
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to