diff options
author | Luke Kanies <luke@reductivelabs.com> | 2010-01-21 22:00:10 -0800 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | c8e89cc1a69ff5827ad40439a2c903c24ae42aba (patch) | |
tree | dafcbf3de176245cf4728b5a7c54bca4ea8e5e42 /spec | |
parent | b7ea1806703df2976d5cd6fade5503c008332526 (diff) | |
download | puppet-c8e89cc1a69ff5827ad40439a2c903c24ae42aba.tar.gz puppet-c8e89cc1a69ff5827ad40439a2c903c24ae42aba.tar.xz puppet-c8e89cc1a69ff5827ad40439a2c903c24ae42aba.zip |
Changing the interface of Puppet::Resource
We need the ability to set the namespace and
environment at initialization so the resource
can look up qualified types.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/integration/util/settings.rb | 1 | ||||
-rwxr-xr-x | spec/unit/resource.rb | 25 | ||||
-rwxr-xr-x | spec/unit/type.rb | 8 |
3 files changed, 24 insertions, 10 deletions
diff --git a/spec/integration/util/settings.rb b/spec/integration/util/settings.rb index 826bfc97e..536eab643 100755 --- a/spec/integration/util/settings.rb +++ b/spec/integration/util/settings.rb @@ -14,7 +14,6 @@ describe Puppet::Util::Settings do it "should be able to make needed directories" do settings = Puppet::Util::Settings.new settings.setdefaults :main, minimal_default_settings.update( :maindir => [tmpfile("main"), "a"] ) - settings.use(:main) File.should be_directory(settings[:maindir]) diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb index 2b1d49d50..bc47fa7ed 100755 --- a/spec/unit/resource.rb +++ b/spec/unit/resource.rb @@ -23,10 +23,6 @@ describe Puppet::Resource do Puppet::Resource.new("file", "/f") end - it "should allow setting of parameters" do - Puppet::Resource.new("file", "/f", :noop => true)[:noop].should be_true - end - it "should tag itself with its type" do Puppet::Resource.new("file", "/f").should be_tagged("file") end @@ -38,6 +34,11 @@ describe Puppet::Resource do it "should not tag itself with its title if the title is a not valid tag" do Puppet::Resource.new("file", "/bar").should_not be_tagged("/bar") end + + it "should allow setting of attributes" do + Puppet::Resource.new("file", "/bar", :file => "/foo").file.should == "/foo" + Puppet::Resource.new("file", "/bar", :exported => true).should be_exported + end end it "should use the resource reference to determine its type" do @@ -89,16 +90,30 @@ describe Puppet::Resource do resource.should be_exported end + it "should support an environment attribute" + + it "should convert its environment into an environment instance if one is provided" + + it "should support a namespace attribute" + describe "when managing parameters" do before do @resource = Puppet::Resource.new("file", "/my/file") end + it "should be able to check whether parameters are valid when the resource models builtin resources" + + it "should be able to check whether parameters are valid when the resource models defined resources" + it "should allow setting and retrieving of parameters" do @resource[:foo] = "bar" @resource[:foo].should == "bar" end + it "should allow setting of parameters at initialization" do + Puppet::Resource.new("file", "/my/file", :parameters => {:foo => "bar"})[:foo].should == "bar" + end + it "should canonicalize retrieved parameter names to treat symbols and strings equivalently" do @resource[:foo] = "bar" @resource["foo"].should == "bar" @@ -255,7 +270,7 @@ describe Puppet::Resource do describe "when converting to puppet code" do before do - @resource = Puppet::Resource.new("one::two", "/my/file", :noop => true, :foo => %w{one two}) + @resource = Puppet::Resource.new("one::two", "/my/file", :parameters => {:noop => true, :foo => %w{one two}}) end it "should print the type and title" do diff --git a/spec/unit/type.rb b/spec/unit/type.rb index f5953aa9c..97dc113a6 100755 --- a/spec/unit/type.rb +++ b/spec/unit/type.rb @@ -164,7 +164,7 @@ describe Puppet::Type do describe "and passed a Puppet::Resource instance" do it "should set its title to the title of the resource if the resource type is equal to the current type" do - resource = Puppet::Resource.new(:mount, "/foo", :name => "/other") + resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "/other"}) Puppet::Type.type(:mount).new(resource).title.should == "/foo" end @@ -191,7 +191,7 @@ describe Puppet::Type do end it "should copy the resource's parameters as its own" do - resource = Puppet::Resource.new(:mount, "/foo", :atboot => true, :fstype => "boo") + resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:atboot => true, :fstype => "boo"}) params = Puppet::Type.type(:mount).new(resource).to_hash params[:fstype].should == "boo" params[:atboot].should == true @@ -253,7 +253,7 @@ describe Puppet::Type do it "should set the attributes in the order returned by the class's :allattrs method" do Puppet::Type.type(:mount).stubs(:allattrs).returns([:name, :atboot, :noop]) - resource = Puppet::Resource.new(:mount, "/foo", :name => "myname", :atboot => "myboot", :noop => "whatever") + resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "myname", :atboot => "myboot", :noop => "whatever"}) set = [] @@ -270,7 +270,7 @@ describe Puppet::Type do it "should always set the name and then default provider before anything else" do Puppet::Type.type(:mount).stubs(:allattrs).returns([:provider, :name, :atboot]) - resource = Puppet::Resource.new(:mount, "/foo", :name => "myname", :atboot => "myboot") + resource = Puppet::Resource.new(:mount, "/foo", :parameters => {:name => "myname", :atboot => "myboot"}) set = [] |