blob: f80221e3dce3c71285b364a574da9878f5e9e280 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../spec_helper'
describe Puppet::Parser::Compiler do
before :each do
@node = Puppet::Node.new "testnode"
@scope_resource = stub 'scope_resource', :builtin? => true, :finish => nil, :ref => 'Class[main]'
@scope = stub 'scope', :resource => @scope_resource, :source => mock("source")
end
after do
Puppet.settings.clear
end
it "should be able to determine the configuration version from a local version control repository" do
# This should always work, because we should always be
# in the puppet repo when we run this.
version = %x{git rev-parse HEAD}.chomp
Puppet.settings[:config_version] = 'git rev-parse HEAD'
@parser = Puppet::Parser::Parser.new "development"
@compiler = Puppet::Parser::Compiler.new(@node)
@compiler.catalog.version.should == version
end
it "should not create duplicate resources when a class is referenced both directly and indirectly by the node classifier (4792)" do
Puppet[:code] = <<-PP
class foo
{
notify { foo_notify: }
include bar
}
class bar
{
notify { bar_notify: }
}
PP
@node.stubs(:classes).returns(['foo', 'bar'])
catalog = Puppet::Parser::Compiler.compile(@node)
catalog.resource("Notify[foo_notify]").should_not be_nil
catalog.resource("Notify[bar_notify]").should_not be_nil
end
describe "when resolving class references" do
it "should favor local scope, even if there's an included class in topscope" do
Puppet[:code] = <<-PP
class experiment {
class baz {
}
notify {"x" : require => Class[Baz] }
}
class baz {
}
include baz
include experiment
include experiment::baz
PP
catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode"))
notify_resource = catalog.resource( "Notify[x]" )
notify_resource[:require].title.should == "Experiment::Baz"
end
it "should favor local scope, even if there's an unincluded class in topscope" do
Puppet[:code] = <<-PP
class experiment {
class baz {
}
notify {"x" : require => Class[Baz] }
}
class baz {
}
include experiment
include experiment::baz
PP
catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode"))
notify_resource = catalog.resource( "Notify[x]" )
notify_resource[:require].title.should == "Experiment::Baz"
end
end
end
|