|
1291 | 1291 | end
|
1292 | 1292 | end
|
1293 | 1293 |
|
| 1294 | + describe "source" do |
| 1295 | + it "should require file resource when specified with the source property" do |
| 1296 | + file = described_class.new(:path => File.expand_path("/foo"), :ensure => :file, :source => File.expand_path("/bar")) |
| 1297 | + source = described_class.new(:path => File.expand_path("/bar"), :ensure => :file) |
| 1298 | + catalog.add_resource file |
| 1299 | + catalog.add_resource source |
| 1300 | + reqs = file.autorequire |
| 1301 | + expect(reqs.size).to eq(1) |
| 1302 | + expect(reqs[0].source).to eq(source) |
| 1303 | + expect(reqs[0].target).to eq(file) |
| 1304 | + end |
| 1305 | + |
| 1306 | + it "should require file resource when specified with the source property as file: URI" do |
| 1307 | + file = described_class.new(:path => File.expand_path("/foo"), :ensure => :file, :source => "file://#{File.expand_path("/bar")}") |
| 1308 | + source = described_class.new(:path => File.expand_path("/bar"), :ensure => :file) |
| 1309 | + catalog.add_resource file |
| 1310 | + catalog.add_resource source |
| 1311 | + reqs = file.autorequire |
| 1312 | + expect(reqs.size).to eq(1) |
| 1313 | + expect(reqs[0].source).to eq(source) |
| 1314 | + expect(reqs[0].target).to eq(file) |
| 1315 | + end |
| 1316 | + |
| 1317 | + it "should require file resource when specified with the source property as an array" do |
| 1318 | + file = described_class.new(:path => File.expand_path("/foo"), :ensure => :file, :source => [File.expand_path("/bar")]) |
| 1319 | + source = described_class.new(:path => File.expand_path("/bar"), :ensure => :file) |
| 1320 | + catalog.add_resource file |
| 1321 | + catalog.add_resource source |
| 1322 | + reqs = file.autorequire |
| 1323 | + expect(reqs.size).to eq(1) |
| 1324 | + expect(reqs[0].source).to eq(source) |
| 1325 | + expect(reqs[0].target).to eq(file) |
| 1326 | + end |
| 1327 | + |
| 1328 | + it "should not require source if source is not local" do |
| 1329 | + file = described_class.new(:path => File.expand_path('/foo'), :ensure => :file, :source => 'puppet:///modules/nfs/conf') |
| 1330 | + catalog.add_resource file |
| 1331 | + expect(file.autorequire.size).to eq(0) |
| 1332 | + end |
| 1333 | + |
| 1334 | + it "should not require source if source is not managed" do |
| 1335 | + file = described_class.new(:path => File.expand_path('/foo'), :ensure => :file, :source => File.expand_path('/bar')) |
| 1336 | + catalog.add_resource file |
| 1337 | + expect(file.autorequire.size).to eq(0) |
| 1338 | + end |
| 1339 | + end |
| 1340 | + |
1294 | 1341 | describe "directories" do
|
1295 | 1342 | it "should autorequire its parent directory" do
|
1296 | 1343 | dir = described_class.new(:path => File.dirname(path))
|
|
0 commit comments