This adds some basic testing around whether url, or plist data is used for the various versions of OS X. Unfortunately this involves stubbing larger sections of the implementation than we'd like, but this did not attempt to re-structure the implementation at all.
Paired-with: Josh Cooper <[email protected]> Signed-off-by: Jacob Helwig <[email protected]> --- Local-branch: tickets/2.6.x/6487-help-directoryservice-provider-work-on-future-OSX-versions Gary, I wish testing this were easier than it was. I agree that the patch you did was pretty simple. Unfortunately the rest of the implementation didn't look quite so simple & straight-forward to test. Thanks for the work you did on the implementation! .../provider/nameservice/directoryservice_spec.rb | 60 ++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) diff --git a/spec/unit/provider/nameservice/directoryservice_spec.rb b/spec/unit/provider/nameservice/directoryservice_spec.rb index 661899d..07f75e3 100755 --- a/spec/unit/provider/nameservice/directoryservice_spec.rb +++ b/spec/unit/provider/nameservice/directoryservice_spec.rb @@ -36,3 +36,63 @@ require File.dirname(__FILE__) + '/../../../spec_helper' end end end + +describe 'DirectoryService.single_report' do + it 'should fail on OS X < 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.3") + + lambda { + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + }.should raise_error(RuntimeError, "Puppet does not support OS X versions < 10.4") + end + + it 'should use url data on 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.4") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + Puppet::Provider::NameService::DirectoryService.stubs(:list_all_present).returns( + ['root', 'user1', 'user2', 'resource_name'] + ) + Puppet::Provider::NameService::DirectoryService.stubs(:generate_attribute_hash) + Puppet::Provider::NameService::DirectoryService.stubs(:execute) + Puppet::Provider::NameService::DirectoryService.expects(:parse_dscl_url_data) + + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + end + + it 'should use plist data on > 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.5") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + Puppet::Provider::NameService::DirectoryService.stubs(:list_all_present).returns( + ['root', 'user1', 'user2', 'resource_name'] + ) + Puppet::Provider::NameService::DirectoryService.stubs(:generate_attribute_hash) + Puppet::Provider::NameService::DirectoryService.stubs(:execute) + Puppet::Provider::NameService::DirectoryService.expects(:parse_dscl_plist_data) + + Puppet::Provider::NameService::DirectoryService.single_report('resource_name') + end +end + +describe 'DirectoryService.get_exec_preamble' do + it 'should fail on OS X < 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.3") + + lambda { + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list') + }.should raise_error(RuntimeError, "Puppet does not support OS X versions < 10.4") + end + + it 'should use url data on 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.4") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list').should include("-url") + end + + it 'should use plist data on > 10.4' do + Puppet::Provider::NameService::DirectoryService.stubs(:get_macosx_version_major).returns("10.5") + Puppet::Provider::NameService::DirectoryService.stubs(:get_ds_path).returns('Users') + + Puppet::Provider::NameService::DirectoryService.get_exec_preamble('-list').should include("-plist") + end +end -- 1.7.4.5 -- 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.
