|
203 | 203 | @provider.should_receive(:run_command).with(:command => expected_cmd, :cwd => "/my/deploy/dir") |
204 | 204 | @provider.sync |
205 | 205 | end |
206 | | - |
| 206 | + |
207 | 207 | it "does a checkout running the clone command then running the after clone command from the destination dir" do |
| 208 | + ::File.stub!(:exist?).with("/my/deploy/dir").and_return(false) |
| 209 | + ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..']) |
208 | 210 | @provider.should_receive(:clone) |
209 | 211 | @provider.should_receive(:checkout) |
210 | 212 | @provider.should_receive(:enable_submodules) |
211 | 213 | @resource.should_receive(:updated=).at_least(1).times.with(true) |
212 | 214 | @provider.action_checkout |
213 | 215 | end |
214 | 216 |
|
| 217 | + it "should not checkout if the destination exists or is a non empty directory" do |
| 218 | + ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true) |
| 219 | + ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar']) |
| 220 | + @provider.should_not_receive(:clone) |
| 221 | + @provider.should_not_receive(:checkout) |
| 222 | + @provider.should_not_receive(:enable_submodules) |
| 223 | + @resource.should_not_receive(:updated=) |
| 224 | + Chef::Log.should_receive(:info).with("Taking no action, checkout destination /my/deploy/dir already exists or is a non-empty directory") |
| 225 | + @provider.action_checkout |
| 226 | + end |
| 227 | + |
215 | 228 | it "does a sync by running the sync command" do |
216 | 229 | ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true) |
217 | 230 | ::Dir.stub!(:entries).and_return(['.','..',"lib", "spec"]) |
|
0 commit comments