diff --git a/CHANGELOG.md b/CHANGELOG.md index 0523c41..aab4775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/FBSnapshotsViewer/Extensions/FileManager+Move.swift b/FBSnapshotsViewer/Extensions/FileManager+Move.swift index 76f8080..4852552 100644 --- a/FBSnapshotsViewer/Extensions/FileManager+Move.swift +++ b/FBSnapshotsViewer/Extensions/FileManager+Move.swift @@ -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) } } diff --git a/FBSnapshotsViewer/Managers/SnapshotTestResultSwapper.swift b/FBSnapshotsViewer/Managers/SnapshotTestResultSwapper.swift index 0960268..e947710 100644 --- a/FBSnapshotsViewer/Managers/SnapshotTestResultSwapper.swift +++ b/FBSnapshotsViewer/Managers/SnapshotTestResultSwapper.swift @@ -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)