diff options
| author | Markus Roberts <Markus@reality.com> | 2009-08-06 22:26:27 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-14 08:49:30 +1000 |
| commit | 75c6e4aed8bf60fbb1bd535fcdd5504f48ce9dde (patch) | |
| tree | cc2c0b42a674b332a5b312f45664f8d36e2d9b75 /spec/unit | |
| parent | b62d9668e04f40f2e3aa6c0f26dd26d1f75d8e22 (diff) | |
| download | puppet-75c6e4aed8bf60fbb1bd535fcdd5504f48ce9dde.tar.gz puppet-75c6e4aed8bf60fbb1bd535fcdd5504f48ce9dde.tar.xz puppet-75c6e4aed8bf60fbb1bd535fcdd5504f48ce9dde.zip | |
Fixes #2493
Added downcasing into find_or_load (which replaced fqfind) to get
back the old behaviour. Adjusted tests so that they would catch
the problem & confirmed that they fail without the downcasing.
Added tests to confirm the existance of #2493; improved
existing autoload tests (removed inter-test interactions)
and noted (with a TODO) that there was dead code in the
feature loading test; added analogus case sensitivity tests
where apropriate.
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/parser/compiler.rb | 10 | ||||
| -rwxr-xr-x | spec/unit/parser/parser.rb | 30 |
2 files changed, 29 insertions, 11 deletions
diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index 0cc6e8a17..ad6f351bf 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -423,6 +423,16 @@ describe Puppet::Parser::Compiler do @compiler.evaluate_classes(%w{myclass}, @scope, false) end + it "should skip classes previously evaluated with different capitalization" do + @compiler.catalog.stubs(:tag) + @scope.stubs(:find_hostclass).with("MyClass").returns(@class) + @compiler.expects(:class_scope).with(@class).returns("something") + @compiler.expects(:add_resource).never + @resource.expects(:evaluate).never + Puppet::Parser::Resource.expects(:new).never + @compiler.evaluate_classes(%w{MyClass}, @scope, false) + end + it "should return the list of found classes" do @compiler.catalog.stubs(:tag) diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb index 75d0c05a3..ff14e205c 100755 --- a/spec/unit/parser/parser.rb +++ b/spec/unit/parser/parser.rb @@ -346,32 +346,40 @@ describe Puppet::Parser do describe Puppet::Parser,"when looking up names" do before :each do @loaded_code = mock 'loaded code' - @loaded_code.stubs(:find_my_type).with('Loaded_namespace', 'Loaded_name').returns(true) - @loaded_code.stubs(:find_my_type).with('Bogus_namespace', 'Bogus_name' ).returns(false) + @loaded_code.stubs(:find_my_type).with('loaded_namespace', 'loaded_name').returns(true) + @loaded_code.stubs(:find_my_type).with('bogus_namespace', 'bogus_name' ).returns(false) @parser = Puppet::Parser::Parser.new :environment => "development",:loaded_code => @loaded_code end describe "that are already loaded" do it "should not try to load anything" do @parser.expects(:load).never - @parser.find_or_load("Loaded_namespace","Loaded_name",:my_type) + @parser.find_or_load("loaded_namespace","loaded_name",:my_type) end it "should return true" do - @parser.find_or_load("Loaded_namespace","Loaded_name",:my_type).should == true + @parser.find_or_load("loaded_namespace","loaded_name",:my_type).should == true end end describe "that aren't already loaded" do - it "should first attempt to load them with the fully qualified name" do - @loaded_code.stubs(:find_my_type).with("Foo_namespace","Foo_name").returns(false,true,true) - @parser.expects(:load).with("Foo_namespace::Foo_name").returns(true).then.raises(Exception) + it "should first attempt to load them with the all lowercase fully qualified name" do + @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,true,true) + @parser.expects(:load).with("foo_namespace::foo_name").returns(true).then.raises(Exception) @parser.find_or_load("Foo_namespace","Foo_name",:my_type).should == true end - it "should next attempt to load them with the namespace" do - @loaded_code.stubs(:find_my_type).with("Foo_namespace","Foo_name").returns(false,false,true,true) - @parser.expects(:load).with("Foo_namespace::Foo_name").returns(false).then.raises(Exception) - @parser.expects(:load).with("Foo_namespace").returns(true).then.raises(Exception) + it "should next attempt to load them with the all lowercase namespace" do + @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,true,true) + @parser.expects(:load).with("foo_namespace::foo_name").returns(false).then.raises(Exception) + @parser.expects(:load).with("foo_namespace" ).returns(true ).then.raises(Exception) + @parser.find_or_load("Foo_namespace","Foo_name",:my_type).should == true + end + + it "should finally attempt to load them with the all lowercase unqualified name" do + @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,false,true,true) + @parser.expects(:load).with("foo_namespace::foo_name").returns(false).then.raises(Exception) + @parser.expects(:load).with("foo_namespace" ).returns(false).then.raises(Exception) + @parser.expects(:load).with( "foo_name").returns(true ).then.raises(Exception) @parser.find_or_load("Foo_namespace","Foo_name",:my_type).should == true end |
