|
141 | 141 | describe "and generating files" do
|
142 | 142 | it "should set the backup on the file if backup is set on the tidy instance" do
|
143 | 143 | @tidy[:backup] = "whatever"
|
144 |
| - expect(Puppet::Type.type(:file)).to receive(:new).with(hash_including(backup: "whatever")) |
145 | 144 |
|
146 |
| - @tidy.mkfile(@basepath) |
| 145 | + expect(@tidy.mkfile(@basepath)[:backup]).to eq("whatever") |
147 | 146 | end
|
148 | 147 |
|
149 | 148 | it "should set the file's path to the tidy's path" do
|
150 |
| - expect(Puppet::Type.type(:file)).to receive(:new).with(hash_including(path: @basepath)) |
151 |
| - |
152 |
| - @tidy.mkfile(@basepath) |
| 149 | + expect(@tidy.mkfile(@basepath)[:path]).to eq(@basepath) |
153 | 150 | end
|
154 | 151 |
|
155 | 152 | it "should configure the file for deletion" do
|
156 |
| - expect(Puppet::Type.type(:file)).to receive(:new).with(hash_including(ensure: :absent)) |
157 |
| - |
158 |
| - @tidy.mkfile(@basepath) |
| 153 | + expect(@tidy.mkfile(@basepath)[:ensure]).to eq(:absent) |
159 | 154 | end
|
160 | 155 |
|
161 | 156 | it "should force deletion on the file" do
|
162 |
| - expect(Puppet::Type.type(:file)).to receive(:new).with(hash_including(force: true)) |
163 |
| - |
164 |
| - @tidy.mkfile(@basepath) |
| 157 | + expect(@tidy.mkfile(@basepath)[:force]).to eq(true) |
165 | 158 | end
|
166 | 159 |
|
167 | 160 | it "should do nothing if the targeted file does not exist" do
|
|
471 | 464 |
|
472 | 465 | expect(result.values).to all(be_noop)
|
473 | 466 | end
|
| 467 | + |
| 468 | + it "generates resources whose schedule parameter matches the managed resource's schedule parameter" do |
| 469 | + @tidy[:recurse] = true |
| 470 | + @tidy[:schedule] = 'fake_schedule' |
| 471 | + |
| 472 | + fileset = double('fileset') |
| 473 | + expect(Puppet::FileServing::Fileset).to receive(:new).with(@basepath, {:recurse => true, :max_files=>0}).and_return(fileset) |
| 474 | + expect(fileset).to receive(:files).and_return(%w{. a a/2 a/1 a/3}) |
| 475 | + allow(@tidy).to receive(:tidy?).and_return(true) |
| 476 | + |
| 477 | + result = @tidy.generate.inject({}) { |hash, res| hash[res[:path]] = res; hash } |
| 478 | + |
| 479 | + result.each do |file_resource| |
| 480 | + expect(file_resource[1][:schedule]).to eq('fake_schedule') |
| 481 | + end |
| 482 | + |
| 483 | + end |
474 | 484 | end
|
475 | 485 |
|
476 | 486 | def lstat_is(path, stat)
|
|
0 commit comments