|
153 | 153 | expect($result)->status->toBe(Status::failed()); |
154 | 154 | }); |
155 | 155 |
|
156 | | -it('will pass if the backup is at least than the given size when loaded from filesystem disk', function (int $sizeInMb) { |
| 156 | +it('will pass if the backup is at least the given size when loaded from filesystem disk', function (int $sizeInMb) { |
157 | 157 |
|
158 | 158 | Storage::fake('backups'); |
159 | 159 |
|
|
199 | 199 | expect($result)->status->toBe(Status::failed()); |
200 | 200 | }); |
201 | 201 |
|
| 202 | +it('can check if the youngest backup is recent enough when loaded from filesystem disk with an immutable date', function () { |
| 203 | + |
| 204 | + Storage::fake('backups'); |
| 205 | + Storage::disk('backups')->put('backups/hey.zip', 'content'); |
| 206 | + |
| 207 | + testTime()->addMinutes(4); |
| 208 | + |
| 209 | + $result = $this->backupsCheck |
| 210 | + ->onDisk('backups') |
| 211 | + ->locatedAt('backups') |
| 212 | + ->youngestBackShouldHaveBeenMadeBefore(now()->subMinutes(5)->startOfMinute()->toImmutable()) |
| 213 | + ->run(); |
| 214 | + |
| 215 | + expect($result)->status->toBe(Status::ok()); |
| 216 | + |
| 217 | + testTime()->addMinutes(2); |
| 218 | + |
| 219 | + $result = $this->backupsCheck |
| 220 | + ->locatedAt($this->temporaryDirectory->path('*.zip')) |
| 221 | + ->youngestBackShouldHaveBeenMadeBefore(now()->subMinutes(5)->toImmutable()) |
| 222 | + ->run(); |
| 223 | + expect($result)->status->toBe(Status::failed()); |
| 224 | +}); |
| 225 | + |
202 | 226 | it('can check if the oldest backup is old enough when loaded from filesystem disk', function () { |
203 | 227 |
|
204 | 228 | Storage::fake('backups'); |
|
223 | 247 | expect($result)->status->toBe(Status::failed()); |
224 | 248 | }); |
225 | 249 |
|
| 250 | +it('can check if the oldest backup is old enough when loaded from filesystem disk with an immutable date', function () { |
| 251 | + |
| 252 | + Storage::fake('backups'); |
| 253 | + Storage::disk('backups')->put('backups/hey.zip', 'content'); |
| 254 | + |
| 255 | + testTime()->addMinutes(4); |
| 256 | + |
| 257 | + $result = $this->backupsCheck |
| 258 | + ->onDisk('backups') |
| 259 | + ->locatedAt('backups') |
| 260 | + ->oldestBackShouldHaveBeenMadeAfter(now()->subMinutes(5)->toImmutable()) |
| 261 | + ->run(); |
| 262 | + |
| 263 | + expect($result)->status->toBe(Status::failed()); |
| 264 | + |
| 265 | + testTime()->addMinutes(2); |
| 266 | + |
| 267 | + $result = $this->backupsCheck |
| 268 | + ->locatedAt($this->temporaryDirectory->path('*.zip')) |
| 269 | + ->oldestBackShouldHaveBeenMadeAfter(now()->subMinutes(5)->toImmutable()) |
| 270 | + ->run(); |
| 271 | + expect($result)->status->toBe(Status::failed()); |
| 272 | +}); |
| 273 | + |
226 | 274 | it('can parse modified time from file name', function ($format) { |
227 | 275 | Storage::fake('backups'); |
228 | 276 |
|
|
0 commit comments