~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/unit/other/transbucket.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
    it "should be able to produce a RAL component" do
11
11
        @bucket.name = "luke"
12
 
        @bucket.type = "user"
 
12
        @bucket.type = "foo"
13
13
 
14
14
        resource = nil
15
 
        proc { resource = @bucket.to_type }.should_not raise_error
 
15
        proc { resource = @bucket.to_ral }.should_not raise_error
16
16
        resource.should be_instance_of(Puppet::Type::Component)
17
 
        resource.title.should == "User[luke]"
 
17
        resource.title.should == "Foo[luke]"
18
18
    end
19
19
 
20
20
    it "should accept TransObjects into its children list" do
91
91
        @fakes = %w{Fake[bottom] Fake[middle] Fake[top]}
92
92
    end
93
93
 
94
 
    after do
95
 
        Puppet::Type.allclear
96
 
    end
97
 
 
98
94
    it "should convert all transportable objects to RAL resources" do
99
95
        @catalog = @top.to_catalog
100
96
        @users.each do |name|
103
99
    end
104
100
 
105
101
    it "should fail if any transportable resources fail to convert to RAL resources" do
106
 
        @bottomobj.expects(:to_type).raises ArgumentError
 
102
        @bottomobj.expects(:to_ral).raises ArgumentError
107
103
        lambda { @bottom.to_catalog }.should raise_error(ArgumentError)
108
104
    end
109
105
 
124
120
        @catalog.vertices.each do |vertex| vertex.should be_finalized end
125
121
    end
126
122
 
127
 
    it "should only call to_type on each resource once" do
 
123
    it "should only call to_ral on each resource once" do
128
124
        # We just raise exceptions here because we're not interested in
129
125
        # what happens with the result, only that the method only
130
126
        # gets called once.
131
 
        resource = @topobj.to_type
132
 
        @topobj.expects(:to_type).once.returns resource
 
127
        resource = @topobj.to_ral
 
128
        @topobj.expects(:to_ral).once.returns resource
133
129
        @top.to_catalog
134
130
    end
135
131
 
136
132
    it "should set each TransObject's catalog before converting to a RAL resource" do
137
 
        @middleobj.expects(:catalog=).with { |c| c.is_a?(Puppet::Node::Catalog) }
 
133
        @middleobj.expects(:catalog=).with { |c| c.is_a?(Puppet::Resource::Catalog) }
138
134
        @top.to_catalog
139
135
    end
140
136
 
141
137
    it "should set each TransBucket's catalog before converting to a RAL resource" do
142
138
        # each bucket is seen twice in the loop, so we have to handle the case where the config
143
139
        # is set twice
144
 
        @bottom.expects(:catalog=).with { |c| c.is_a?(Puppet::Node::Catalog) }.at_least_once
 
140
        @bottom.expects(:catalog=).with { |c| c.is_a?(Puppet::Resource::Catalog) }.at_least_once
145
141
        @top.to_catalog
146
142
    end
147
143
end
170
166
        children.should == %w{one two}
171
167
    end
172
168
end
 
169
 
 
170
describe Puppet::TransBucket, " when converting to a Puppet::Resource" do
 
171
    before do
 
172
        @trans = Puppet::TransBucket.new
 
173
        @trans.name = "foo"
 
174
        @trans.type = "bar"
 
175
        @trans.param(:noop, true)
 
176
    end
 
177
 
 
178
    it "should create a resource with the correct type and title" do
 
179
        result = @trans.to_resource
 
180
        result.type.should == "Bar"
 
181
        result.title.should == "foo"
 
182
    end
 
183
 
 
184
    it "should add all of its parameters to the created resource" do
 
185
        @trans.param(:noop, true)
 
186
        @trans.to_resource[:noop].should be_true
 
187
    end
 
188
end