diff options
| author | Jeffrey McCune <mccune.jeff@gmail.com> | 2008-11-28 22:39:22 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-12-01 18:05:06 +1100 |
| commit | 9329c95d6fbb2df5e8b754620427645f6eae69b9 (patch) | |
| tree | 5694255e239a405e9418be9dce4166afc354053d /spec | |
| parent | 83b3a1ec2a98edeab12a5eb9c4b107a6fe08613c (diff) | |
type/mcx.rb Feature #1026 - MCX Type
Added new MCX type and base test.
This type manages MCX settings on DirectoryService nodes. These
settings take the form of plist XML documents attached to Users,
Groups, and Computers in DirectoryService.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/provider/mcx/mcxcontent.rb | 68 | ||||
| -rwxr-xr-x | spec/unit/type/mcx.rb | 62 |
2 files changed, 130 insertions, 0 deletions
diff --git a/spec/unit/provider/mcx/mcxcontent.rb b/spec/unit/provider/mcx/mcxcontent.rb new file mode 100755 index 000000000..6cb3fc78e --- /dev/null +++ b/spec/unit/provider/mcx/mcxcontent.rb @@ -0,0 +1,68 @@ +#! /usr/bin/env ruby +#-- +# Copyright (C) 2008 Jeffrey J McCune. + +# This program and entire repository is free software; you can +# redistribute it and/or modify it under the terms of the GNU +# General Public License as published by the Free Software +# Foundation; either version 2 of the License, or any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Author: Jeff McCune <mccune.jeff@gmail.com> + +require File.dirname(__FILE__) + '/../../../spec_helper' + +provider_class = Puppet::Type.type(:mcx).provider(:mcxcontent) + +describe provider_class do + + before :each do + # Create a mock resource + @resource = stub 'resource' + + @provider = provider_class.new + @attached_to = "/Users/katie" + + # A catch all; no parameters set + @resource.stubs(:[]).returns(nil) + + # But set name, ensure and enable + @resource.stubs(:[]).with(:name).returns @attached_to + @resource.stubs(:[]).with(:enable).returns :true + @resource.stubs(:ref).returns "Mcx[#{@attached_to}]" + + # stub out the provider methods that actually touch the filesystem + # or execute commands + @provider.stubs(:execute).returns("") + @provider.stubs(:resource).returns @resource + end + + it "should have a create method." do + @provider.should respond_to(:create) + end + + it "should have a destroy method." do + @provider.should respond_to(:destroy) + end + + it "should have an exists? method." do + @provider.should respond_to(:exists?) + end + + it "should have an content method." do + @provider.should respond_to(:content) + end + + it "should have an content= method." do + @provider.should respond_to(:content=) + end + +end diff --git a/spec/unit/type/mcx.rb b/spec/unit/type/mcx.rb new file mode 100755 index 000000000..fb67f07d9 --- /dev/null +++ b/spec/unit/type/mcx.rb @@ -0,0 +1,62 @@ +#!/usr/bin/env ruby +#-- +# Copyright (C) 2008 Jeffrey J McCune. + +# This program and entire repository is free software; you can +# redistribute it and/or modify it under the terms of the GNU +# General Public License as published by the Free Software +# Foundation; either version 2 of the License, or any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Author: Jeff McCune <mccune.jeff@gmail.com> + +# Most of this code copied from /spec/type/service.rb + +require File.dirname(__FILE__) + '/../../spec_helper' + +require "puppet/type/mcx" + +describe Puppet::Type.type(:mcx), "when validating attributes" do + + [:name, :ds_type, :ds_name].each do |param| + it "should have a #{param} parameter" do + Puppet::Type.type(:mcx).attrtype(param).should == :param + end + end + + [:ensure, :content].each do |param| + it "should have a #{param} property" do + Puppet::Type.type(:mcx).attrtype(param).should == :property + end + end + +end + +describe Puppet::Type.type(:mcx), "when validating attribute values" do + + before do + @provider = stub 'provider', :class => Puppet::Type.type(:mcx).defaultprovider, :clear => nil, :controllable? => false + Puppet::Type.type(:mcx).defaultprovider.stubs(:new).returns(@provider) + end + + after do + Puppet::Type.type(:mcx).clear + end + + it "should support :present as a value to :ensure" do + Puppet::Type.type(:mcx).create(:name => "/Foo/bar", :ensure => :present) + end + + it "should support :absent as a value to :ensure" do + Puppet::Type.type(:mcx).create(:name => "/Foo/bar", :ensure => :absent) + end + +end |
