Skip to content

Commit

Permalink
Enable acceptance of AutoRecorded images.
Browse files Browse the repository at this point in the history
Enable image to be accepted (“swapped”) as a reference image, when an original reference image does not exist.
  • Loading branch information
babbage committed Apr 7, 2018
1 parent 707ede6 commit fae6734
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 0.8.1 (Next)

* Your contribution here.
* [#72](https://github.com/Antondomashnev/FBSnapshotsViewer/pull/72): Recognise and enable acceptance of AutoRecorded images. - [@babbage](https://github.com/babbage).

### 0.8.0 (11.10.2017)

Expand Down
4 changes: 3 additions & 1 deletion FBSnapshotsViewer/Extensions/FileManager+Move.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import Foundation

extension FileManager {
func moveItem(at fromURL: URL, to toURL: URL) throws {
try self.removeItem(at: toURL)
if fileExists(atPath: toURL.path) {
try self.removeItem(at: toURL)
}
try self.copyItem(at: fromURL, to: toURL)
}
}
2 changes: 1 addition & 1 deletion FBSnapshotsViewer/Managers/SnapshotTestResultSwapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SnapshotTestResultSwapper {
let failedImageSizeSuffix = imagePath.substring(with: failedImageSizeSuffixRange)
let recordedImageURLs = testResult.build.fbReferenceImageDirectoryURLs.flatMap { fbReferenceImageDirectoryURL -> URL? in
let url = fbReferenceImageDirectoryURL.appendingPathComponent(testResult.testClassName).appendingPathComponent("\(testResult.testName)\(failedImageSizeSuffix)").appendingPathExtension("png")
return fileManager.fileExists(atPath: url.path) ? url : nil
return url
}
guard let url = recordedImageURLs.first else {
throw SnapshotTestResultSwapperError.notExistedRecordedImage(testResult: testResult)
Expand Down

0 comments on commit fae6734

Please sign in to comment.