From de76664bed995983bb6bf14b6e238d0cedca5f87 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 10 Jun 2017 14:13:31 +0100 Subject: [PATCH] Add Build structure; #trivial (#42) --- .codebeatignore | 2 ++ FBSnapshotsViewer.xcodeproj/project.pbxproj | 4 +++ .../External Viewers/KaleidoscopeViewer.swift | 4 +-- ...pplicationSnapshotTestResultListener.swift | 11 +++++-- .../Managers/SnapshotTestResultFactory.swift | 14 ++++----- FBSnapshotsViewer/Models/Build.swift | 24 +++++++++++++++ .../Models/SnapshotTestResult.swift | 29 ++++++------------- .../Presenter/TestResultDisplayInfo.swift | 8 ++--- ...cationSnapshotTestResultListenerSpec.swift | 16 +++++----- .../KaleidoscopeViewerSpec.swift | 14 ++++++--- .../MenuInteractorSpec.swift | 10 ++++--- .../MenuPresenterSpec.swift | 9 +++--- .../SnapshotTestResultFactorySpec.swift | 25 ++++++++-------- .../TestResultDisplayInfoSpec.swift | 12 ++++---- ...TestResultsCollectionViewOutletsSpec.swift | 3 +- .../TestResultsControllerSpec.swift | 7 +++-- .../TestResultsInteractorSpec.swift | 5 ++-- .../TestResultsPresenterSpec.swift | 8 +++-- .../AutoEquatable.generated.swift | 13 ++++++--- .../AutoHashable.generated.swift | 6 ++++ 20 files changed, 139 insertions(+), 85 deletions(-) create mode 100644 .codebeatignore create mode 100644 FBSnapshotsViewer/Models/Build.swift diff --git a/.codebeatignore b/.codebeatignore new file mode 100644 index 0000000..5002527 --- /dev/null +++ b/.codebeatignore @@ -0,0 +1,2 @@ +fastlane/** +Vendor/** diff --git a/FBSnapshotsViewer.xcodeproj/project.pbxproj b/FBSnapshotsViewer.xcodeproj/project.pbxproj index c29dbc9..3914f3b 100644 --- a/FBSnapshotsViewer.xcodeproj/project.pbxproj +++ b/FBSnapshotsViewer.xcodeproj/project.pbxproj @@ -81,6 +81,7 @@ 6D789CE61EC3BFA900EEF7EE /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D789CE51EC3BFA800EEF7EE /* Configuration.swift */; }; 6D789CE81EC3C19F00EEF7EE /* ConfigurationStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D789CE71EC3C19F00EEF7EE /* ConfigurationStorage.swift */; }; 6D7C1F921EEB35CB0045117E /* AppCodeLog.xml in Resources */ = {isa = PBXBuildFile; fileRef = 6DEFF5761EE89E010048F16B /* AppCodeLog.xml */; }; + 6D7C1F941EEC198A0045117E /* Build.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D7C1F931EEC198A0045117E /* Build.swift */; }; 6D7D78FE1EAFF2430001C1A0 /* SnapshotTestResultFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D7D78FD1EAFF2430001C1A0 /* SnapshotTestResultFactory.swift */; }; 6D7D79001EAFF2A80001C1A0 /* ApplicationLogLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D7D78FF1EAFF2A80001C1A0 /* ApplicationLogLine.swift */; }; 6D7D79021EB081F50001C1A0 /* ApplicationSnapshotTestResultListenerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D7D79011EB081F50001C1A0 /* ApplicationSnapshotTestResultListenerFactory.swift */; }; @@ -222,6 +223,7 @@ 6D789CE31EC3BEF800EEF7EE /* PreferencesInteractorIO.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesInteractorIO.swift; sourceTree = ""; }; 6D789CE51EC3BFA800EEF7EE /* Configuration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = ""; }; 6D789CE71EC3C19F00EEF7EE /* ConfigurationStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurationStorage.swift; sourceTree = ""; }; + 6D7C1F931EEC198A0045117E /* Build.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Build.swift; sourceTree = ""; }; 6D7D78FD1EAFF2430001C1A0 /* SnapshotTestResultFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotTestResultFactory.swift; sourceTree = ""; }; 6D7D78FF1EAFF2A80001C1A0 /* ApplicationLogLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationLogLine.swift; sourceTree = ""; }; 6D7D79011EB081F50001C1A0 /* ApplicationSnapshotTestResultListenerFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationSnapshotTestResultListenerFactory.swift; sourceTree = ""; }; @@ -638,6 +640,7 @@ 6D342CDF1EBBDF80006EEBEC /* AppleInterfaceMode.swift */, 6D789CD91EC3B38C00EEF7EE /* DerivedDataFolderType.swift */, 6D789CE51EC3BFA800EEF7EE /* Configuration.swift */, + 6D7C1F931EEC198A0045117E /* Build.swift */, ); path = Models; sourceTree = ""; @@ -968,6 +971,7 @@ 6DDFBDA41E64D14700DFC0A4 /* MenuModuleInterface.swift in Sources */, 6D789CE81EC3C19F00EEF7EE /* ConfigurationStorage.swift in Sources */, 6D4724BD1E3E9F2400F38161 /* AppDelegate.swift in Sources */, + 6D7C1F941EEC198A0045117E /* Build.swift in Sources */, 6D848C591E68D3960000FC1E /* TestResultDisplayInfo.swift in Sources */, 6D5BB4C51E5915A10006BAE1 /* ApplicationTemporaryFolderEventFilter.swift in Sources */, 6D848C5D1E68D6A50000FC1E /* TestResultsInteractor.swift in Sources */, diff --git a/FBSnapshotsViewer/External Viewers/KaleidoscopeViewer.swift b/FBSnapshotsViewer/External Viewers/KaleidoscopeViewer.swift index 6fb0786..8c08da8 100644 --- a/FBSnapshotsViewer/External Viewers/KaleidoscopeViewer.swift +++ b/FBSnapshotsViewer/External Viewers/KaleidoscopeViewer.swift @@ -22,14 +22,14 @@ class KaleidoscopeViewer: ExternalViewer { } static func canView(snapshotTestResult: SnapshotTestResult) -> Bool { - if case SnapshotTestResult.failed(_, _, _, _, _, _) = snapshotTestResult { + if case SnapshotTestResult.failed(_, _, _, _, _) = snapshotTestResult { return true } return false } static func view(snapshotTestResult: SnapshotTestResult, using processLauncher: ProcessLauncher = ProcessLauncher()) { - guard case let SnapshotTestResult.failed(_, referenceImagePath, _, failedImagePath, _, _) = snapshotTestResult else { + guard case let SnapshotTestResult.failed(_, referenceImagePath, _, failedImagePath, _) = snapshotTestResult else { assertionFailure("Trying to open Kaleidoscope viewer for test result without diff") return } diff --git a/FBSnapshotsViewer/Listeners/ApplicationSnapshotTestResultListener.swift b/FBSnapshotsViewer/Listeners/ApplicationSnapshotTestResultListener.swift index 5e55bb3..331715b 100644 --- a/FBSnapshotsViewer/Listeners/ApplicationSnapshotTestResultListener.swift +++ b/FBSnapshotsViewer/Listeners/ApplicationSnapshotTestResultListener.swift @@ -12,8 +12,8 @@ import KZFileWatchers typealias ApplicationSnapshotTestResultListenerOutput = (SnapshotTestResult) -> Void class ApplicationSnapshotTestResultListener { + private var build: Build? private var readLinesNumber: Int = 0 - private var readApplicationName: String = "" private var listeningOutput: ApplicationSnapshotTestResultListenerOutput? private let fileWatcher: KZFileWatchers.FileWatcherProtocol private let applicationLogReader: ApplicationLogReader @@ -85,10 +85,14 @@ class ApplicationSnapshotTestResultListener { case .unknown: return nil case .applicationNameMessage: - readApplicationName = try applicationNameExtractor.extractApplicationName(from: logLine) + build = Build(applicationName: try applicationNameExtractor.extractApplicationName(from: logLine)) return nil default: - return snapshotTestResultFactory.createSnapshotTestResult(from: logLine, applicationName: readApplicationName) + guard let build = build else { + assertionFailure("Unexpected snapshot test result line \(logLine) before build information line") + return nil + } + return snapshotTestResultFactory.createSnapshotTestResult(from: logLine, build: build) } } snapshotTestResults.forEach { listeningOutput($0) } @@ -98,6 +102,7 @@ class ApplicationSnapshotTestResultListener { private func reset() { readLinesNumber = 0 listeningOutput = nil + build = nil try? fileWatcher.stop() } } diff --git a/FBSnapshotsViewer/Managers/SnapshotTestResultFactory.swift b/FBSnapshotsViewer/Managers/SnapshotTestResultFactory.swift index 1ab47bf..d11124d 100644 --- a/FBSnapshotsViewer/Managers/SnapshotTestResultFactory.swift +++ b/FBSnapshotsViewer/Managers/SnapshotTestResultFactory.swift @@ -38,7 +38,7 @@ class SnapshotTestResultFactory { return "\(testClassName) \(testName)" } - private func createSnapshotTestResult(fromKaleidoscopeCommandLine line: String, applicationName: String) throws -> SnapshotTestResult { + private func createSnapshotTestResult(fromKaleidoscopeCommandLine line: String, build: Build) throws -> SnapshotTestResult { let lineComponents = line.components(separatedBy: "\"") guard lineComponents.count == 5 else { throw SnapshotTestResultFactoryError.unexpectedKaleidoscopeCommandLineFormat @@ -47,31 +47,31 @@ class SnapshotTestResultFactory { let failedImagePath = lineComponents[3] let diffImagePath = failedImagePath.replacingOccurrences(of: "/failed_", with: "/diff_") let testName = try extractTestName(fromFailedImage: failedImagePath) - return SnapshotTestResult.failed(testName: testName, referenceImagePath: referenceImagePath, diffImagePath: diffImagePath, failedImagePath: failedImagePath, createdAt: Date(), applicationName: applicationName) + return SnapshotTestResult.failed(testName: testName, referenceImagePath: referenceImagePath, diffImagePath: diffImagePath, failedImagePath: failedImagePath, build: build) } - private func createSnapshotTestResult(fromSavedReferenceImageLine line: String, applicationName: String) throws -> SnapshotTestResult { + private func createSnapshotTestResult(fromSavedReferenceImageLine line: String, build: Build) throws -> SnapshotTestResult { let lineComponents = line.components(separatedBy: ApplicationLogLine.referenceImageSavedMessageIndicatorSubstring) guard lineComponents.count == 2 else { throw SnapshotTestResultFactoryError.unexpectedSavedReferenceImageLineFormat } let referenceImagePath = lineComponents[1] let testName = try extractTestName(fromSavedReferenceImage: referenceImagePath) - return SnapshotTestResult.recorded(testName: testName, referenceImagePath: referenceImagePath, createdAt: Date(), applicationName: applicationName) + return SnapshotTestResult.recorded(testName: testName, referenceImagePath: referenceImagePath, build: build) } // MARK: - Interface - func createSnapshotTestResult(from logLine: ApplicationLogLine, applicationName: String = "") -> SnapshotTestResult? { + func createSnapshotTestResult(from logLine: ApplicationLogLine, build: Build) -> SnapshotTestResult? { switch logLine { case .unknown: return nil case .applicationNameMessage: return nil case let .kaleidoscopeCommandMessage(line): - return try? self.createSnapshotTestResult(fromKaleidoscopeCommandLine: line, applicationName: applicationName) + return try? self.createSnapshotTestResult(fromKaleidoscopeCommandLine: line, build: build) case let .referenceImageSavedMessage(line): - return try? self.createSnapshotTestResult(fromSavedReferenceImageLine: line, applicationName: applicationName) + return try? self.createSnapshotTestResult(fromSavedReferenceImageLine: line, build: build) } } } diff --git a/FBSnapshotsViewer/Models/Build.swift b/FBSnapshotsViewer/Models/Build.swift new file mode 100644 index 0000000..03edb59 --- /dev/null +++ b/FBSnapshotsViewer/Models/Build.swift @@ -0,0 +1,24 @@ +// +// Build.swift +// FBSnapshotsViewer +// +// Created by Anton Domashnev on 10.06.17. +// Copyright © 2017 Anton Domashnev. All rights reserved. +// + +import Foundation + +struct Build: AutoHashable, AutoEquatable { + let date: Date + let applicationName: String + + init(date: Date, applicationName: String) { + self.applicationName = applicationName + self.date = date + } + + init(applicationName: String) { + self.date = Date() + self.applicationName = applicationName + } +} diff --git a/FBSnapshotsViewer/Models/SnapshotTestResult.swift b/FBSnapshotsViewer/Models/SnapshotTestResult.swift index c999858..8435568 100644 --- a/FBSnapshotsViewer/Models/SnapshotTestResult.swift +++ b/FBSnapshotsViewer/Models/SnapshotTestResult.swift @@ -11,40 +11,29 @@ import Cocoa enum SnapshotTestResult: AutoEquatable { var testName: String { switch self { - case let .recorded(testName, _, _, _): + case let .recorded(testName, _, _): return testName - case let .failed(testName, _, _, _, _, _): + case let .failed(testName, _, _, _, _): return testName } } - var createdAt: Date { + var build: Build { switch self { - case let .recorded(_, _, createdAt, _): - return createdAt - case let .failed(_, _, _, _, createdAt, _): - return createdAt - } - } - - var applicationName: String { - switch self { - case let .recorded(_, _, _, applicationNamw): - return applicationNamw - case let .failed(_, _, _, _, _, applicationName): - return applicationName + case let .recorded(_, _, build): + return build + case let .failed(_, _, _, _, build): + return build } } case recorded(testName: String, referenceImagePath: String, - createdAt: Date, - applicationName: String) + build: Build) case failed(testName: String, referenceImagePath: String, diffImagePath: String, failedImagePath: String, - createdAt: Date, - applicationName: String) + build: Build) } diff --git a/FBSnapshotsViewer/Test Results/Presenter/TestResultDisplayInfo.swift b/FBSnapshotsViewer/Test Results/Presenter/TestResultDisplayInfo.swift index 935c484..46799cb 100644 --- a/FBSnapshotsViewer/Test Results/Presenter/TestResultDisplayInfo.swift +++ b/FBSnapshotsViewer/Test Results/Presenter/TestResultDisplayInfo.swift @@ -23,20 +23,20 @@ struct TestResultDisplayInfo: AutoEquatable { self.testResult = testResult self.canBeViewedInKaleidoscope = kaleidoscopeViewer.isAvailable() && kaleidoscopeViewer.canView(snapshotTestResult: testResult) switch testResult { - case let .recorded(_, referenceImagePath, _, _): + case let .recorded(_, referenceImagePath, _): self.referenceImageURL = URL(fileURLWithPath: referenceImagePath) self.diffImageURL = nil self.failedImageURL = nil - case let .failed(_, referenceImagePath, diffImagePath, failedImagePath, _, _): + case let .failed(_, referenceImagePath, diffImagePath, failedImagePath, _): self.referenceImageURL = URL(fileURLWithPath: referenceImagePath) self.diffImageURL = URL(fileURLWithPath: diffImagePath) self.failedImageURL = URL(fileURLWithPath: failedImagePath) } - self.createdAt = dateFormatter.string(from: testResult.createdAt, to: Date()) ?? "Just now" + self.createdAt = dateFormatter.string(from: testResult.build.date, to: Date()) ?? "Just now" let testNameComponents = testResult.testName.replacingOccurrences(of: "_", with: " ").components(separatedBy: " ") self.testContext = testNameComponents[0..<(testNameComponents.count - 1)].joined(separator: " ") self.testName = testNameComponents[testNameComponents.count - 1] - self.applicationName = testResult.applicationName + self.applicationName = testResult.build.applicationName } } diff --git a/FBSnapshotsViewerTests/ApplicationSnapshotTestResultListenerSpec.swift b/FBSnapshotsViewerTests/ApplicationSnapshotTestResultListenerSpec.swift index 664212c..8f1786e 100644 --- a/FBSnapshotsViewerTests/ApplicationSnapshotTestResultListenerSpec.swift +++ b/FBSnapshotsViewerTests/ApplicationSnapshotTestResultListenerSpec.swift @@ -39,9 +39,9 @@ class ApplicationSnapshotTestResultListener_MockApplicationLogReader: Applicatio class ApplicationSnapshotTestResultListener_MockSnapshotTestResultFactory: SnapshotTestResultFactory { var createdSnapshotTestResultForLogLine: [ApplicationLogLine: SnapshotTestResult] = [:] - var givenApplicationName: String! - override func createSnapshotTestResult(from logLine: ApplicationLogLine, applicationName: String) -> SnapshotTestResult? { - givenApplicationName = applicationName + var givenBuild: Build! + override func createSnapshotTestResult(from logLine: ApplicationLogLine, build: Build) -> SnapshotTestResult? { + givenBuild = build return createdSnapshotTestResultForLogLine[logLine] } } @@ -87,12 +87,13 @@ class ApplicationSnapshotTestResultListenerSpec: QuickSpec { describe(".receiving new file watch event") { var receivedSnapshotTestResults: [SnapshotTestResult] = [] + let build = Build(date: Date(), applicationName: "MyApp") let unknownLogLine = ApplicationLogLine.unknown let applicationNameMessageLogLine = ApplicationLogLine.applicationNameMessage(line: "MyApp") let kaleidoscopeCommandMesageLogLine = ApplicationLogLine.kaleidoscopeCommandMessage(line: "BlaBla") let referenceImageSavedMessageLogLine = ApplicationLogLine.referenceImageSavedMessage(line: "FooFoo") - let failedSnapshotTestResult = SnapshotTestResult.failed(testName: "failedTest", referenceImagePath: "referenceTestImage.png", diffImagePath: "diffTestImage.png", failedImagePath: "failedTestImage.png", createdAt: Date(), applicationName: "MyApp") - let recordedSnapshotTestResult = SnapshotTestResult.recorded(testName: "recordedTest", referenceImagePath: "referenceTestImage.png", createdAt: Date(), applicationName: "MyApp") + let failedSnapshotTestResult = SnapshotTestResult.failed(testName: "failedTest", referenceImagePath: "referenceTestImage.png", diffImagePath: "diffTestImage.png", failedImagePath: "failedTestImage.png", build: build) + let recordedSnapshotTestResult = SnapshotTestResult.recorded(testName: "recordedTest", referenceImagePath: "referenceTestImage.png", build: build) beforeEach { applicationNameExtractor.extractApplicationNameReturnValue = "MyApp" @@ -142,8 +143,9 @@ class ApplicationSnapshotTestResultListenerSpec: QuickSpec { expect(receivedSnapshotTestResults).to(equal([failedSnapshotTestResult, recordedSnapshotTestResult])) } - it("creates test results with correct application name") { - expect(snapshotTestResultFactory.givenApplicationName).to(equal(applicationNameExtractor.extractApplicationNameReturnValue)) + it("creates test results with correct build") { + expect(snapshotTestResultFactory.givenBuild.applicationName) == applicationNameExtractor.extractApplicationNameReturnValue + expect(snapshotTestResultFactory.givenBuild.date.timeIntervalSince1970).to(beCloseTo(Date().timeIntervalSince1970, within: 0.01)) } } } diff --git a/FBSnapshotsViewerTests/KaleidoscopeViewerSpec.swift b/FBSnapshotsViewerTests/KaleidoscopeViewerSpec.swift index 65ba876..c29486a 100644 --- a/FBSnapshotsViewerTests/KaleidoscopeViewerSpec.swift +++ b/FBSnapshotsViewerTests/KaleidoscopeViewerSpec.swift @@ -55,10 +55,12 @@ class KaleidoscopeViewerSpec: QuickSpec { describe(".canView") { var testResult: SnapshotTestResult! + var build: Build! context("for recorded snapshot test result") { beforeEach { - testResult = SnapshotTestResult.recorded(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", createdAt: Date(), applicationName: "MyApp") + build = Build(applicationName: "MyApp") + testResult = SnapshotTestResult.recorded(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", build: build) } it("returns false") { @@ -68,7 +70,8 @@ class KaleidoscopeViewerSpec: QuickSpec { context("for failed snapshot test result") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", diffImagePath: "foo/bar/diffImage.png", failedImagePath: "foo/bar/failedImage.png", createdAt: Date(), applicationName: "MyApp") + build = Build(applicationName: "MyApp") + testResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", diffImagePath: "foo/bar/diffImage.png", failedImagePath: "foo/bar/failedImage.png", build: build) } it("returns true") { @@ -101,10 +104,12 @@ class KaleidoscopeViewerSpec: QuickSpec { describe(".view") { var testResult: SnapshotTestResult! + var build: Build! context("for recorded snapshot test result") { beforeEach { - testResult = SnapshotTestResult.recorded(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", createdAt: Date(), applicationName: "MyApp") + build = Build(date: Date(), applicationName: "MyApp") + testResult = SnapshotTestResult.recorded(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", build: build) } it("throws an assertion") { @@ -114,7 +119,8 @@ class KaleidoscopeViewerSpec: QuickSpec { context("for failed snapshot test result") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", diffImagePath: "foo/bar/diffImage.png", failedImagePath: "foo/bar/failedImage.png", createdAt: Date(), applicationName: "MyApp") + build = Build(date: Date(), applicationName: "MyApp") + testResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "foo/bar/referenceImage.png", diffImagePath: "foo/bar/diffImage.png", failedImagePath: "foo/bar/failedImage.png", build: build) } it("launches correct process") { diff --git a/FBSnapshotsViewerTests/MenuInteractorSpec.swift b/FBSnapshotsViewerTests/MenuInteractorSpec.swift index a325534..687f29f 100644 --- a/FBSnapshotsViewerTests/MenuInteractorSpec.swift +++ b/FBSnapshotsViewerTests/MenuInteractorSpec.swift @@ -51,9 +51,10 @@ class MenuInteractorSpec: QuickSpec { override func spec() { let testResultsDate = Date() let applicationName = "FBSnapshotsViewer" - let testResult1 = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", createdAt: testResultsDate, applicationName: applicationName) - let testResult2 = SnapshotTestResult.failed(testName: "testName2", referenceImagePath: "referenceImagePath2", diffImagePath: "diffImagePath2", failedImagePath: "failedImagePath2", createdAt: testResultsDate, applicationName: applicationName) - let testResult3 = SnapshotTestResult.recorded(testName: "testName3", referenceImagePath: "referenceImagePath3", createdAt: testResultsDate, applicationName: applicationName) + let build = Build(date: testResultsDate, applicationName: applicationName) + let testResult1 = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", build: build) + let testResult2 = SnapshotTestResult.failed(testName: "testName2", referenceImagePath: "referenceImagePath2", diffImagePath: "diffImagePath2", failedImagePath: "failedImagePath2", build: build) + let testResult3 = SnapshotTestResult.recorded(testName: "testName3", referenceImagePath: "referenceImagePath3", build: build) var configuration: FBSnapshotsViewer.Configuration! var applicationNameExtractor: ApplicationNameExtractorMock! @@ -121,7 +122,8 @@ class MenuInteractorSpec: QuickSpec { } it("outputs it") { - let expectedTestResult = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", createdAt: testResultsDate, applicationName: applicationName) + let build = Build(date: testResultsDate, applicationName: applicationName) + let expectedTestResult = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", build: build) expect(output.didFindNewTestResultReceivedTestResult).to(equal(expectedTestResult)) } } diff --git a/FBSnapshotsViewerTests/MenuPresenterSpec.swift b/FBSnapshotsViewerTests/MenuPresenterSpec.swift index 4872e89..07499d3 100644 --- a/FBSnapshotsViewerTests/MenuPresenterSpec.swift +++ b/FBSnapshotsViewerTests/MenuPresenterSpec.swift @@ -27,7 +27,7 @@ class MenuPresenter_MockMenuWireframe: MenuWireframe { class MenuPresenterSpec: QuickSpec { override func spec() { - let testResultsDate = Date() + var build: Build! var configuration: FBSnapshotsViewer.Configuration! var derivedDataFolder: DerivedDataFolder! var application: ApplicationMock! @@ -38,6 +38,7 @@ class MenuPresenterSpec: QuickSpec { var updater: UpdaterMock! beforeEach { + build = Build(date: Date(), applicationName: "FBSnapshotsViewer") updater = UpdaterMock() derivedDataFolder = DerivedDataFolder.xcodeCustom(path: "Users/antondomashnev/Library/Xcode/temporaryFolder") configuration = FBSnapshotsViewer.Configuration(derivedDataFolder: derivedDataFolder) @@ -114,7 +115,7 @@ class MenuPresenterSpec: QuickSpec { describe(".didFindNewTestResult") { beforeEach { - presenter.didFindNewTestResult(SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", createdAt: testResultsDate, applicationName: "MyApp")) + presenter.didFindNewTestResult(SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", build: build)) } it("sets that new test results are available in user interface") { @@ -128,7 +129,7 @@ class MenuPresenterSpec: QuickSpec { var foundTestResults: [SnapshotTestResult] = [] beforeEach { - foundTestResults = [SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", createdAt: testResultsDate, applicationName: "MyApp")] + foundTestResults = [SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", build: build)] interactor.foundTestResults = foundTestResults presenter.showTestResults() } @@ -139,7 +140,7 @@ class MenuPresenterSpec: QuickSpec { } it("shows test results") { - let expectedPaameter = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", createdAt: testResultsDate, applicationName: "MyApp") + let expectedPaameter = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", build: build) expect(wireframe.showTestResultsModuleCalled).to(beTrue()) expect(wireframe.showTestResultsModuleReceivedParameters[0]).to(equal(expectedPaameter)) } diff --git a/FBSnapshotsViewerTests/SnapshotTestResultFactorySpec.swift b/FBSnapshotsViewerTests/SnapshotTestResultFactorySpec.swift index 8ba80c8..9cb6424 100644 --- a/FBSnapshotsViewerTests/SnapshotTestResultFactorySpec.swift +++ b/FBSnapshotsViewerTests/SnapshotTestResultFactorySpec.swift @@ -13,11 +13,11 @@ import Nimble class SnapshotTestResultFactorySpec: QuickSpec { override func spec() { - var applicationName: String! + var build: Build! var factory: SnapshotTestResultFactory! beforeEach { - applicationName = "FBSnapshotsViewer" + build = Build(applicationName: "FBSnapshotsViewer") factory = SnapshotTestResultFactory() } @@ -26,7 +26,7 @@ class SnapshotTestResultFactorySpec: QuickSpec { var createdTestResult: SnapshotTestResult? beforeEach { - createdTestResult = factory.createSnapshotTestResult(from: .unknown) + createdTestResult = factory.createSnapshotTestResult(from: .unknown, build: build) } it("doesnt create test result") { @@ -45,7 +45,7 @@ class SnapshotTestResultFactorySpec: QuickSpec { } it("returns nil") { - expect(factory.createSnapshotTestResult(from: referenceImageSavedMessage)).to(beNil()) + expect(factory.createSnapshotTestResult(from: referenceImageSavedMessage, build: build)).to(beNil()) } } @@ -55,7 +55,7 @@ class SnapshotTestResultFactorySpec: QuickSpec { } it("returns nil") { - expect(factory.createSnapshotTestResult(from: referenceImageSavedMessage)).to(beNil()) + expect(factory.createSnapshotTestResult(from: referenceImageSavedMessage, build: build)).to(beNil()) } } } @@ -63,13 +63,12 @@ class SnapshotTestResultFactorySpec: QuickSpec { context("when valid") { beforeEach { referenceImageSavedMessage = ApplicationLogLine.referenceImageSavedMessage(line: "Reference image save at: /Users/antondomashnev/Work/FBSnapshotsViewerExample/FBSnapshotsViewerExampleTests/ReferenceImages_64/FBSnapshotsViewerExampleTests/testRecord@2x.png") - createdTestResult = factory.createSnapshotTestResult(from: referenceImageSavedMessage, applicationName: applicationName) + createdTestResult = factory.createSnapshotTestResult(from: referenceImageSavedMessage, build: build) } it("creates recorded test result") { - let expectedTestResult = SnapshotTestResult.recorded(testName: "FBSnapshotsViewerExampleTests testRecord", referenceImagePath: "/Users/antondomashnev/Work/FBSnapshotsViewerExample/FBSnapshotsViewerExampleTests/ReferenceImages_64/FBSnapshotsViewerExampleTests/testRecord@2x.png", createdAt: createdTestResult.createdAt, applicationName: applicationName) + let expectedTestResult = SnapshotTestResult.recorded(testName: "FBSnapshotsViewerExampleTests testRecord", referenceImagePath: "/Users/antondomashnev/Work/FBSnapshotsViewerExample/FBSnapshotsViewerExampleTests/ReferenceImages_64/FBSnapshotsViewerExampleTests/testRecord@2x.png", build: build) expect(createdTestResult).to(equal(expectedTestResult)) - expect(createdTestResult.createdAt.timeIntervalSince1970).to(beCloseTo(Date().timeIntervalSince1970, within: 0.01)) } } } @@ -85,7 +84,7 @@ class SnapshotTestResultFactorySpec: QuickSpec { } it("returns nil") { - expect(factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage)).to(beNil()) + expect(factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage, build: build)).to(beNil()) } } @@ -95,7 +94,7 @@ class SnapshotTestResultFactorySpec: QuickSpec { } it("returns nil") { - expect(factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage)).to(beNil()) + expect(factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage, build: build)).to(beNil()) } } } @@ -103,13 +102,13 @@ class SnapshotTestResultFactorySpec: QuickSpec { context("when valid") { beforeEach { kaleidoscopeCommandMessage = ApplicationLogLine.kaleidoscopeCommandMessage(line: "ksdiff \"/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/reference_testFail@2x.png\" \"/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/failed_testFail@2x.png\"") - createdTestResult = factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage, applicationName: applicationName) + createdTestResult = factory.createSnapshotTestResult(from: kaleidoscopeCommandMessage, build: build) } it("creates failed test result") { - let expectedTestResult = SnapshotTestResult.failed(testName: "FBSnapshotsViewerExampleTests testFail", referenceImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/reference_testFail@2x.png", diffImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/diff_testFail@2x.png", failedImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/failed_testFail@2x.png", createdAt: createdTestResult.createdAt, applicationName: applicationName) + let expectedTestResult = SnapshotTestResult.failed(testName: "FBSnapshotsViewerExampleTests testFail", referenceImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/reference_testFail@2x.png", diffImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/diff_testFail@2x.png", failedImagePath: "/Users/antondomashnev/Library/Developer/CoreSimulator/Devices/B1AC0517-7FC0-4B32-8543-9EC263071FE5/data/Containers/Data/Application/8EEE157C-41B9-47F8-8634-CF3D60962E19/tmp/FBSnapshotsViewerExampleTests/failed_testFail@2x.png", build: build) expect(createdTestResult).to(equal(expectedTestResult)) - expect(createdTestResult.createdAt.timeIntervalSince1970).to(beCloseTo(Date().timeIntervalSince1970, within: 0.01)) + } } } diff --git a/FBSnapshotsViewerTests/TestResultDisplayInfoSpec.swift b/FBSnapshotsViewerTests/TestResultDisplayInfoSpec.swift index 651b6e6..f4c639c 100644 --- a/FBSnapshotsViewerTests/TestResultDisplayInfoSpec.swift +++ b/FBSnapshotsViewerTests/TestResultDisplayInfoSpec.swift @@ -47,6 +47,7 @@ class TestResultDisplayInfo_MockKaleidoscopeViewer: ExternalViewer { class TestResultDisplayInfoSpec: QuickSpec { override func spec() { describe(".initWithTestInfo") { + var build: Build! var testResult: SnapshotTestResult! var dateFormatter: TestResultDisplayInfo_MockDateComponentsFormatter! let kaleidoscopeViewer: TestResultDisplayInfo_MockKaleidoscopeViewer.Type = TestResultDisplayInfo_MockKaleidoscopeViewer.self @@ -62,7 +63,8 @@ class TestResultDisplayInfoSpec: QuickSpec { describe("testName") { context("when test name with undrscore") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "TestClass_testName_has_replaced_all_underscore_with_spaces", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + build = Build(date: Date(), applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.failed(testName: "TestClass_testName_has_replaced_all_underscore_with_spaces", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", build: build) } it("has correct test name") { @@ -78,7 +80,7 @@ class TestResultDisplayInfoSpec: QuickSpec { context("when test name without undrscore") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "TestClass testName", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.failed(testName: "TestClass testName", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", build: build) } it("has correct test name") { @@ -95,7 +97,7 @@ class TestResultDisplayInfoSpec: QuickSpec { describe("canBeViewedInKaleidoscope") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "testFailed", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.failed(testName: "testFailed", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", build: build) } context("when kaleidoscope viewer is available") { @@ -140,7 +142,7 @@ class TestResultDisplayInfoSpec: QuickSpec { context("when failed test result") { beforeEach { - testResult = SnapshotTestResult.failed(testName: "TestClass testFailed", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.failed(testName: "TestClass testFailed", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", build: build) } it("initializes object correctly") { @@ -157,7 +159,7 @@ class TestResultDisplayInfoSpec: QuickSpec { context("when recorded test result") { beforeEach { - testResult = SnapshotTestResult.recorded(testName: "ExampleTestClass testRecord", referenceImagePath: "referenceImagePath.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.recorded(testName: "ExampleTestClass testRecord", referenceImagePath: "referenceImagePath.png", build: build) } it("initializes object correctly") { diff --git a/FBSnapshotsViewerTests/TestResultsCollectionViewOutletsSpec.swift b/FBSnapshotsViewerTests/TestResultsCollectionViewOutletsSpec.swift index 81738f7..38c0ea9 100644 --- a/FBSnapshotsViewerTests/TestResultsCollectionViewOutletsSpec.swift +++ b/FBSnapshotsViewerTests/TestResultsCollectionViewOutletsSpec.swift @@ -50,7 +50,8 @@ class TestResultsCollectionViewOutletsSpec: QuickSpec { var testResults: [TestResultDisplayInfo] = [] beforeEach { - let snapshotTestResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", createdAt: Date(), applicationName: "MyApp") + let build = Build(date: Date(), applicationName: "MyApp") + let snapshotTestResult = SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath.png", diffImagePath: "diffImagePath.png", failedImagePath: "failedImagePath.png", build: build) let testResult = TestResultDisplayInfo(testResult: snapshotTestResult) testResults = [testResult] collectionViewOutlets.testResults = testResults diff --git a/FBSnapshotsViewerTests/TestResultsControllerSpec.swift b/FBSnapshotsViewerTests/TestResultsControllerSpec.swift index 0c9ace1..5c6b5dd 100644 --- a/FBSnapshotsViewerTests/TestResultsControllerSpec.swift +++ b/FBSnapshotsViewerTests/TestResultsControllerSpec.swift @@ -28,6 +28,7 @@ class TestResultsController_MockTestResultsCollectionViewOutlets: TestResultsCol class TestResultsControllerSpec: QuickSpec { override func spec() { + let build: Build = Build(date: Date(), applicationName: "FBSnapshotsViewer") var collectionViewOutlets: TestResultsController_MockTestResultsCollectionViewOutlets! var collectionView: TestResultsController_MockNSCollectionView! var controller: TestResultsController! @@ -47,7 +48,7 @@ class TestResultsControllerSpec: QuickSpec { var testResults: [TestResultDisplayInfo]! beforeEach { - let testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", createdAt: Date(), applicationName: "MyApp")) + let testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", build: build)) testResults = [testResultDisplayInfo] controller.show(testResults: testResults) } @@ -92,7 +93,7 @@ class TestResultsControllerSpec: QuickSpec { context("when test result is not presented in controller") { beforeEach { - let testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", createdAt: Date(), applicationName: "MyApp")) + let testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", build: build)) collectionViewOutlets.testResults = [testResultDisplayInfo] collectionView.indexPathForItemReturnValue = IndexPath(item: 1, section: 0) } @@ -106,7 +107,7 @@ class TestResultsControllerSpec: QuickSpec { var testResultDisplayInfo: TestResultDisplayInfo! beforeEach { - testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", createdAt: Date(), applicationName: "MyApp")) + testResultDisplayInfo = TestResultDisplayInfo(testResult: SnapshotTestResult.recorded(testName: "Bla", referenceImagePath: "foo/bar.png", build: build)) collectionViewOutlets.testResults = [testResultDisplayInfo] collectionView.indexPathForItemReturnValue = IndexPath(item: 0, section: 0) controller.testResultCell(cell, viewInKaleidoscopeButtonClicked: viewInKaleidoscopeButton) diff --git a/FBSnapshotsViewerTests/TestResultsInteractorSpec.swift b/FBSnapshotsViewerTests/TestResultsInteractorSpec.swift index 907b9b6..e4d07f6 100644 --- a/FBSnapshotsViewerTests/TestResultsInteractorSpec.swift +++ b/FBSnapshotsViewerTests/TestResultsInteractorSpec.swift @@ -39,14 +39,15 @@ class TestResultsInteractor_Mock: ExternalViewer { class TestResultsInteractorSpec: QuickSpec { override func spec() { + let build: Build = Build(date: Date(), applicationName: "MyApp") let kaleidoscopeViewer: TestResultsInteractor_Mock.Type = TestResultsInteractor_Mock.self var processLauncher: ProcessLauncher! var interactor: TestResultsInteractor! var testResults: [SnapshotTestResult] = [] beforeEach { - let testResult1 = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", createdAt: Date(), applicationName: "MyApp") - let testResult2 = SnapshotTestResult.recorded(testName: "testName2", referenceImagePath: "referenceImagePath2", createdAt: Date(), applicationName: "MyApp") + let testResult1 = SnapshotTestResult.failed(testName: "testName1", referenceImagePath: "referenceImagePath1", diffImagePath: "diffImagePath1", failedImagePath: "failedImagePath1", build: build) + let testResult2 = SnapshotTestResult.recorded(testName: "testName2", referenceImagePath: "referenceImagePath2", build: build) testResults = [testResult1, testResult2] processLauncher = ProcessLauncher() interactor = TestResultsInteractor(testResults: testResults, kaleidoscopeViewer: kaleidoscopeViewer, processLauncher: processLauncher) diff --git a/FBSnapshotsViewerTests/TestResultsPresenterSpec.swift b/FBSnapshotsViewerTests/TestResultsPresenterSpec.swift index 39a55d7..ad1819c 100644 --- a/FBSnapshotsViewerTests/TestResultsPresenterSpec.swift +++ b/FBSnapshotsViewerTests/TestResultsPresenterSpec.swift @@ -28,9 +28,11 @@ class TestResultsPresenterSpec: QuickSpec { describe(".openInKaleidoscope") { var testResult: SnapshotTestResult! var testResultDisplayInfo: TestResultDisplayInfo! + var build: Build! beforeEach { - testResult = SnapshotTestResult.recorded(testName: "MyTest", referenceImagePath: "foo/bar.png", createdAt: Date(), applicationName: "FBSnapshotsViewer") + build = Build(applicationName: "FBSnapshotsViewer") + testResult = SnapshotTestResult.recorded(testName: "MyTest", referenceImagePath: "foo/bar.png", build: build) testResultDisplayInfo = TestResultDisplayInfo(testResult: testResult) presenter.openInKaleidoscope(testResultDisplayInfo: testResultDisplayInfo) } @@ -54,9 +56,11 @@ class TestResultsPresenterSpec: QuickSpec { context("when interactor has test results") { var testResults: [SnapshotTestResult] = [] + var build: Build! beforeEach { - testResults = [SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", createdAt: Date(), applicationName: "FBSnapshotsViewer")] + build = Build(applicationName: "FBSnapshotsViewer") + testResults = [SnapshotTestResult.failed(testName: "testName", referenceImagePath: "referenceImagePath", diffImagePath: "diffImagePath", failedImagePath: "failedImagePath", build: build)] interactor.testResults = testResults presenter.updateUserInterface() } diff --git a/Vendor/Sourcery/CodeGenerated/AutoEquatable.generated.swift b/Vendor/Sourcery/CodeGenerated/AutoEquatable.generated.swift index 2a21822..9e13bee 100644 --- a/Vendor/Sourcery/CodeGenerated/AutoEquatable.generated.swift +++ b/Vendor/Sourcery/CodeGenerated/AutoEquatable.generated.swift @@ -23,6 +23,13 @@ fileprivate func compareArrays(lhs: [T], rhs: [T], compare: (_ lhs: T, _ rhs: } // MARK: - AutoEquatable for classes, protocols, structs +// MARK: - Build AutoEquatable +extension Build: Equatable {} +internal func == (lhs: Build, rhs: Build) -> Bool { + guard lhs.date == rhs.date else { return false } + guard lhs.applicationName == rhs.applicationName else { return false } + return true +} // MARK: - TestResultDisplayInfo AutoEquatable extension TestResultDisplayInfo: Equatable {} internal func == (lhs: TestResultDisplayInfo, rhs: TestResultDisplayInfo) -> Bool { @@ -115,16 +122,14 @@ internal func == (lhs: SnapshotTestResult, rhs: SnapshotTestResult) -> Bool { case (.recorded(let lhs), .recorded(let rhs)): if lhs.testName != rhs.testName { return false } if lhs.referenceImagePath != rhs.referenceImagePath { return false } - if lhs.createdAt != rhs.createdAt { return false } - if lhs.applicationName != rhs.applicationName { return false } + if lhs.build != rhs.build { return false } return true case (.failed(let lhs), .failed(let rhs)): if lhs.testName != rhs.testName { return false } if lhs.referenceImagePath != rhs.referenceImagePath { return false } if lhs.diffImagePath != rhs.diffImagePath { return false } if lhs.failedImagePath != rhs.failedImagePath { return false } - if lhs.createdAt != rhs.createdAt { return false } - if lhs.applicationName != rhs.applicationName { return false } + if lhs.build != rhs.build { return false } return true default: return false } diff --git a/Vendor/Sourcery/CodeGenerated/AutoHashable.generated.swift b/Vendor/Sourcery/CodeGenerated/AutoHashable.generated.swift index 4dbcc37..584bbdb 100644 --- a/Vendor/Sourcery/CodeGenerated/AutoHashable.generated.swift +++ b/Vendor/Sourcery/CodeGenerated/AutoHashable.generated.swift @@ -20,6 +20,12 @@ fileprivate func combineHashValues(_ initial: Int, _ other: Int) -> Int { } // MARK: - AutoHashable for classes, protocols, structs +// MARK: - Build AutoHashable +extension Build: Hashable { + internal var hashValue: Int { + return combineHashes([date.hashValue, applicationName.hashValue, 0]) + } +} // MARK: - AutoHashable for Enums