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
|
module PuppetTest::ResourceTesting
Parser = Puppet::Parser
AST = Puppet::Parser::AST
def mkclassframing(interp = nil)
interp ||= mkinterp
interp.newdefine("resource", :arguments => [%w{one}, %w{two value}, %w{three}])
interp.newclass("")
source = interp.newclass("base")
interp.newclass("sub1", :parent => "base")
interp.newclass("sub2", :parent => "base")
interp.newclass("other")
scope = Parser::Scope.new(:interp => interp)
scope.source = source
return interp, scope, source
end
def mkresource(args = {})
if args[:scope] and ! args[:source]
args[:source] = args[:scope].source
end
unless args[:scope]
unless defined? @scope
raise "Must set @scope to mkresource"
end
end
{:type => "resource", :title => "testing",
:source => @source, :scope => @scope}.each do |param, value|
args[param] ||= value
end
unless args[:source].is_a?(Puppet::Parser::AST::HostClass)
args[:source] = args[:scope].findclass(args[:source])
end
params = args[:params] || {:one => "yay", :three => "rah"}
if args[:params] == :none
args.delete(:params)
else
args[:params] = paramify args[:source], params
end
Parser::Resource.new(args)
end
def param(name, value, source)
Parser::Resource::Param.new(:name => name, :value => value, :source => source)
end
def paramify(source, hash)
hash.collect do |name, value|
Parser::Resource::Param.new(
:name => name, :value => value, :source => source
)
end
end
end
# $Id$
|