blob: 054b0377a5b5c8e850fd86f05d796e24b219579b (
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
|
#!/usr/bin/env ruby
require 'spec_helper'
require 'puppet/resource/catalog'
Puppet::Resource::Catalog.indirection.terminus(:compiler)
describe Puppet::Resource::Catalog::Compiler do
before do
Facter.stubs(:value).returns "something"
@catalog = Puppet::Resource::Catalog.new
@catalog.add_resource(@one = Puppet::Resource.new(:file, "/one"))
@catalog.add_resource(@two = Puppet::Resource.new(:file, "/two"))
end
after { Puppet.settings.clear }
it "should remove virtual resources when filtering" do
@one.virtual = true
Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
end
it "should not remove exported resources when filtering" do
@one.exported = true
Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.sort.should == [ @one.ref, @two.ref ]
end
it "should remove virtual exported resources when filtering" do
@one.exported = true
@one.virtual = true
Puppet::Resource::Catalog.indirection.terminus.filter(@catalog).resource_refs.should == [ @two.ref ]
end
it "should filter out virtual resources when finding a catalog" do
@one.virtual = true
request = stub 'request', :name => "mynode"
Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
Puppet::Resource::Catalog.indirection.find(request).resource_refs.should == [ @two.ref ]
end
it "should not filter out exported resources when finding a catalog" do
@one.exported = true
request = stub 'request', :name => "mynode"
Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
Puppet::Resource::Catalog.indirection.find(request).resource_refs.sort.should == [ @one.ref, @two.ref ]
end
it "should filter out virtual exported resources when finding a catalog" do
@one.exported = true
@one.virtual = true
request = stub 'request', :name => "mynode"
Puppet::Resource::Catalog.indirection.terminus.stubs(:extract_facts_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:node_from_request)
Puppet::Resource::Catalog.indirection.terminus.stubs(:compile).returns(@catalog)
Puppet::Resource::Catalog.indirection.find(request).resource_refs.should == [ @two.ref ]
end
end
|