diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2010-07-27 10:17:44 -0700 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2010-07-27 10:17:44 -0700 |
| commit | b53e7d78e2e87571ae53170e9716b9ccd75da6e2 (patch) | |
| tree | 58489a37bd0ee14b3d053a0e23f9638b4f6205e7 /spec/unit/node | |
| parent | 94edd404130b4236f0c65a579857e3a25c5ee17f (diff) | |
| parent | ecf44e4408c168893d74af58a4c7c8606634a844 (diff) | |
Merge commit '2.6.1rc1' into next
Diffstat (limited to 'spec/unit/node')
| -rwxr-xr-x | spec/unit/node/environment_spec.rb | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb index b400865a2..6edcce56c 100755 --- a/spec/unit/node/environment_spec.rb +++ b/spec/unit/node/environment_spec.rb @@ -53,6 +53,7 @@ describe Puppet::Node::Environment do @env = Puppet::Node::Environment.new("dev") @collection = Puppet::Resource::TypeCollection.new(@env) @collection.stubs(:perform_initial_import) + Thread.current[:known_resource_types] = nil end it "should create a resource type collection if none exists" do @@ -71,13 +72,41 @@ describe Puppet::Node::Environment do @env.known_resource_types end - it "should create and return a new collection rather than returning a stale collection" do - @env.known_resource_types.expects(:stale?).returns true + it "should return the same collection even if stale if it's the same thread" do + Puppet::Resource::TypeCollection.stubs(:new).returns @collection + @env.known_resource_types.stubs(:stale?).returns true - Puppet::Resource::TypeCollection.expects(:new).returns @collection + @env.known_resource_types.should equal(@collection) + end + + it "should return the current thread associated collection if there is one" do + Thread.current[:known_resource_types] = @collection @env.known_resource_types.should equal(@collection) end + + it "should give to all threads the same collection if it didn't change" do + Puppet::Resource::TypeCollection.expects(:new).with(@env).returns @collection + @env.known_resource_types + + t = Thread.new { + @env.known_resource_types.should equal(@collection) + } + t.join + end + + it "should give to new threads a new collection if it isn't stale" do + Puppet::Resource::TypeCollection.expects(:new).with(@env).returns @collection + @env.known_resource_types.expects(:stale?).returns(true) + + Puppet::Resource::TypeCollection.expects(:new).returns @collection + + t = Thread.new { + @env.known_resource_types.should equal(@collection) + } + t.join + end + end [:modulepath, :manifestdir].each do |setting| |
