From 880843d8e646d5f91a41003882b9d8666c0b439e Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:09:31 -0400 Subject: [PATCH] Rename `*Mock` as `Mock*`. Resolve #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Tests/masTests/Commands/HomeSpec.swift | 2 +- Tests/masTests/Commands/LuckySpec.swift | 2 +- Tests/masTests/Commands/OpenSpec.swift | 2 +- Tests/masTests/Commands/OutdatedSpec.swift | 2 +- Tests/masTests/Commands/UninstallSpec.swift | 2 +- Tests/masTests/Commands/VendorSpec.swift | 2 +- .../Controllers/ITunesSearchAppStoreSearcherSpec.swift | 4 ++-- .../masTests/Controllers/SoftwareMapAppLibrarySpec.swift | 8 ++++---- Tests/masTests/Extensions/Bundle+JSON.swift | 2 +- ...ystemCommandMock.swift => MockOpenSystemCommand.swift} | 4 ++-- Tests/masTests/Formatters/AppListFormatterSpec.swift | 6 +++--- ...oftwareProductMock.swift => MockSoftwareProduct.swift} | 4 ++-- Tests/masTests/Models/SoftwareProductSpec.swift | 2 +- ...ockFromFile.swift => MockFromFileNetworkSession.swift} | 4 ++-- ...{NetworkSessionMock.swift => MockNetworkSession.swift} | 4 ++-- Tests/masTests/Network/NetworkManagerTests.swift | 8 ++++---- 16 files changed, 29 insertions(+), 29 deletions(-) rename Tests/masTests/ExternalCommands/{OpenSystemCommandMock.swift => MockOpenSystemCommand.swift} (85%) rename Tests/masTests/Models/{SoftwareProductMock.swift => MockSoftwareProduct.swift} (80%) rename Tests/masTests/Network/{NetworkSessionMockFromFile.swift => MockFromFileNetworkSession.swift} (91%) rename Tests/masTests/Network/{NetworkSessionMock.swift => MockNetworkSession.swift} (89%) diff --git a/Tests/masTests/Commands/HomeSpec.swift b/Tests/masTests/Commands/HomeSpec.swift index 8e04cf9..8d3faac 100644 --- a/Tests/masTests/Commands/HomeSpec.swift +++ b/Tests/masTests/Commands/HomeSpec.swift @@ -14,7 +14,7 @@ import Quick public class HomeSpec: QuickSpec { override public func spec() { let searcher = MockAppStoreSearcher() - let openCommand = OpenSystemCommandMock() + let openCommand = MockOpenSystemCommand() beforeSuite { MAS.initialize() diff --git a/Tests/masTests/Commands/LuckySpec.swift b/Tests/masTests/Commands/LuckySpec.swift index cf35504..e288739 100644 --- a/Tests/masTests/Commands/LuckySpec.swift +++ b/Tests/masTests/Commands/LuckySpec.swift @@ -13,7 +13,7 @@ import Quick public class LuckySpec: QuickSpec { override public func spec() { - let networkSession = NetworkSessionMockFromFile(responseFile: "search/slack.json") + let networkSession = MockFromFileNetworkSession(responseFile: "search/slack.json") let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) beforeSuite { diff --git a/Tests/masTests/Commands/OpenSpec.swift b/Tests/masTests/Commands/OpenSpec.swift index 8459f7b..5f3ee72 100644 --- a/Tests/masTests/Commands/OpenSpec.swift +++ b/Tests/masTests/Commands/OpenSpec.swift @@ -15,7 +15,7 @@ import Quick public class OpenSpec: QuickSpec { override public func spec() { let searcher = MockAppStoreSearcher() - let openCommand = OpenSystemCommandMock() + let openCommand = MockOpenSystemCommand() beforeSuite { MAS.initialize() diff --git a/Tests/masTests/Commands/OutdatedSpec.swift b/Tests/masTests/Commands/OutdatedSpec.swift index 5831c56..95ced8e 100644 --- a/Tests/masTests/Commands/OutdatedSpec.swift +++ b/Tests/masTests/Commands/OutdatedSpec.swift @@ -38,7 +38,7 @@ public class OutdatedSpec: QuickSpec { let mockAppLibrary = MockAppLibrary() mockAppLibrary.installedApps.append( - SoftwareProductMock( + MockSoftwareProduct( appName: mockSearchResult.trackName, bundleIdentifier: mockSearchResult.bundleId, bundlePath: "/Applications/Bandwidth+.app", diff --git a/Tests/masTests/Commands/UninstallSpec.swift b/Tests/masTests/Commands/UninstallSpec.swift index bfd68d0..7ea7c44 100644 --- a/Tests/masTests/Commands/UninstallSpec.swift +++ b/Tests/masTests/Commands/UninstallSpec.swift @@ -19,7 +19,7 @@ public class UninstallSpec: QuickSpec { } xdescribe("uninstall command") { let appID: AppID = 12345 - let app = SoftwareProductMock( + let app = MockSoftwareProduct( appName: "Some App", bundleIdentifier: "com.some.app", bundlePath: "/tmp/Some.app", diff --git a/Tests/masTests/Commands/VendorSpec.swift b/Tests/masTests/Commands/VendorSpec.swift index 8291658..1834cb3 100644 --- a/Tests/masTests/Commands/VendorSpec.swift +++ b/Tests/masTests/Commands/VendorSpec.swift @@ -14,7 +14,7 @@ import Quick public class VendorSpec: QuickSpec { override public func spec() { let searcher = MockAppStoreSearcher() - let openCommand = OpenSystemCommandMock() + let openCommand = MockOpenSystemCommand() beforeSuite { MAS.initialize() diff --git a/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift b/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift index 3e9f9cd..3b72ee8 100644 --- a/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift +++ b/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift @@ -33,7 +33,7 @@ public class ITunesSearchAppStoreSearcherSpec: QuickSpec { describe("store") { context("when searched") { it("can find slack") { - let networkSession = NetworkSessionMockFromFile(responseFile: "search/slack.json") + let networkSession = MockFromFileNetworkSession(responseFile: "search/slack.json") let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) expect { @@ -46,7 +46,7 @@ public class ITunesSearchAppStoreSearcherSpec: QuickSpec { context("when lookup used") { it("can find slack") { let appID: AppID = 803_453_959 - let networkSession = NetworkSessionMockFromFile(responseFile: "lookup/slack.json") + let networkSession = MockFromFileNetworkSession(responseFile: "lookup/slack.json") let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) var result: SearchResult? diff --git a/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift b/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift index 47b29f4..c4e50ca 100644 --- a/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift +++ b/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift @@ -13,7 +13,7 @@ import Quick public class SoftwareMapAppLibrarySpec: QuickSpec { override public func spec() { - let library = SoftwareMapAppLibrary(softwareMap: SoftwareMapMock(products: apps)) + let library = SoftwareMapAppLibrary(softwareMap: MockSoftwareMap(products: apps)) beforeSuite { MAS.initialize() @@ -31,7 +31,7 @@ public class SoftwareMapAppLibrarySpec: QuickSpec { } // MARK: - Test Data -let myApp = SoftwareProductMock( +let myApp = MockSoftwareProduct( appName: "MyApp", bundleIdentifier: "com.example", bundlePath: "/Applications/MyApp.app", @@ -41,8 +41,8 @@ let myApp = SoftwareProductMock( var apps: [SoftwareProduct] = [myApp] -// MARK: - SoftwareMapMock -struct SoftwareMapMock: SoftwareMap { +// MARK: - MockSoftwareMap +struct MockSoftwareMap: SoftwareMap { var products: [SoftwareProduct] = [] func allSoftwareProducts() -> [SoftwareProduct] { diff --git a/Tests/masTests/Extensions/Bundle+JSON.swift b/Tests/masTests/Extensions/Bundle+JSON.swift index d74c2c0..19c2c0d 100644 --- a/Tests/masTests/Extensions/Bundle+JSON.swift +++ b/Tests/masTests/Extensions/Bundle+JSON.swift @@ -26,7 +26,7 @@ extension Bundle { static func url(for fileName: String) -> URL? { // The Swift Package Manager places resources in a separate bundle from the executable. // https://forums.swift.org/t/swift-5-3-spm-resources-in-tests-uses-wrong-bundle-path/37051 - let bundleURL = Bundle(for: NetworkSessionMock.self) + let bundleURL = Bundle(for: MockNetworkSession.self) .bundleURL .deletingLastPathComponent() .appendingPathComponent("mas_masTests.bundle") diff --git a/Tests/masTests/ExternalCommands/OpenSystemCommandMock.swift b/Tests/masTests/ExternalCommands/MockOpenSystemCommand.swift similarity index 85% rename from Tests/masTests/ExternalCommands/OpenSystemCommandMock.swift rename to Tests/masTests/ExternalCommands/MockOpenSystemCommand.swift index 08d0f4b..da30e13 100644 --- a/Tests/masTests/ExternalCommands/OpenSystemCommandMock.swift +++ b/Tests/masTests/ExternalCommands/MockOpenSystemCommand.swift @@ -1,5 +1,5 @@ // -// OpenSystemCommandMock.swift +// MockOpenSystemCommand.swift // masTests // // Created by Ben Chatelain on 1/4/19. @@ -10,7 +10,7 @@ import Foundation @testable import mas -class OpenSystemCommandMock: ExternalCommand { +class MockOpenSystemCommand: ExternalCommand { // Stub out protocol logic var succeeded = true var arguments: [String] = [] diff --git a/Tests/masTests/Formatters/AppListFormatterSpec.swift b/Tests/masTests/Formatters/AppListFormatterSpec.swift index e8c61d6..1b92397 100644 --- a/Tests/masTests/Formatters/AppListFormatterSpec.swift +++ b/Tests/masTests/Formatters/AppListFormatterSpec.swift @@ -28,7 +28,7 @@ public class AppListFormatterSpec: QuickSpec { expect(format(products)).to(beEmpty()) } it("can format a single product") { - let product = SoftwareProductMock( + let product = MockSoftwareProduct( appName: "Awesome App", bundleIdentifier: "", bundlePath: "", @@ -39,14 +39,14 @@ public class AppListFormatterSpec: QuickSpec { } it("can format two products") { products = [ - SoftwareProductMock( + MockSoftwareProduct( appName: "Awesome App", bundleIdentifier: "", bundlePath: "", bundleVersion: "19.2.1", itemIdentifier: 12345 ), - SoftwareProductMock( + MockSoftwareProduct( appName: "Even Better App", bundleIdentifier: "", bundlePath: "", diff --git a/Tests/masTests/Models/SoftwareProductMock.swift b/Tests/masTests/Models/MockSoftwareProduct.swift similarity index 80% rename from Tests/masTests/Models/SoftwareProductMock.swift rename to Tests/masTests/Models/MockSoftwareProduct.swift index 91de06b..ca03bc7 100644 --- a/Tests/masTests/Models/SoftwareProductMock.swift +++ b/Tests/masTests/Models/MockSoftwareProduct.swift @@ -1,5 +1,5 @@ // -// SoftwareProductMock.swift +// MockSoftwareProduct.swift // masTests // // Created by Ben Chatelain on 12/27/18. @@ -10,7 +10,7 @@ import Foundation @testable import mas -struct SoftwareProductMock: SoftwareProduct { +struct MockSoftwareProduct: SoftwareProduct { var appName: String var bundleIdentifier: String var bundlePath: String diff --git a/Tests/masTests/Models/SoftwareProductSpec.swift b/Tests/masTests/Models/SoftwareProductSpec.swift index ef0e6f1..cd5e15a 100644 --- a/Tests/masTests/Models/SoftwareProductSpec.swift +++ b/Tests/masTests/Models/SoftwareProductSpec.swift @@ -18,7 +18,7 @@ public class SoftwareProductSpec: QuickSpec { MAS.initialize() } describe("software product") { - let app = SoftwareProductMock( + let app = MockSoftwareProduct( appName: "App", bundleIdentifier: "", bundlePath: "", diff --git a/Tests/masTests/Network/NetworkSessionMockFromFile.swift b/Tests/masTests/Network/MockFromFileNetworkSession.swift similarity index 91% rename from Tests/masTests/Network/NetworkSessionMockFromFile.swift rename to Tests/masTests/Network/MockFromFileNetworkSession.swift index 2ab1fa1..893f15e 100644 --- a/Tests/masTests/Network/NetworkSessionMockFromFile.swift +++ b/Tests/masTests/Network/MockFromFileNetworkSession.swift @@ -1,5 +1,5 @@ // -// NetworkSessionMockFromFile.swift +// MockFromFileNetworkSession.swift // masTests // // Created by Ben Chatelain on 2019-01-05. @@ -10,7 +10,7 @@ import Foundation import PromiseKit /// Mock NetworkSession for testing with saved JSON response payload files. -class NetworkSessionMockFromFile: NetworkSessionMock { +class MockFromFileNetworkSession: MockNetworkSession { /// Path to response payload file relative to test bundle. private let responseFile: String diff --git a/Tests/masTests/Network/NetworkSessionMock.swift b/Tests/masTests/Network/MockNetworkSession.swift similarity index 89% rename from Tests/masTests/Network/NetworkSessionMock.swift rename to Tests/masTests/Network/MockNetworkSession.swift index 31274cc..504ff32 100644 --- a/Tests/masTests/Network/NetworkSessionMock.swift +++ b/Tests/masTests/Network/MockNetworkSession.swift @@ -1,5 +1,5 @@ // -// NetworkSessionMock +// MockNetworkSession // masTests // // Created by Ben Chatelain on 11/13/18. @@ -12,7 +12,7 @@ import PromiseKit @testable import mas /// Mock NetworkSession for testing. -class NetworkSessionMock: NetworkSession { +class MockNetworkSession: NetworkSession { // Properties that enable us to set exactly what data or error // we want our mocked URLSession to return for any request. var data: Data? diff --git a/Tests/masTests/Network/NetworkManagerTests.swift b/Tests/masTests/Network/NetworkManagerTests.swift index 751271c..6f3e520 100644 --- a/Tests/masTests/Network/NetworkManagerTests.swift +++ b/Tests/masTests/Network/NetworkManagerTests.swift @@ -18,7 +18,7 @@ class NetworkManagerTests: XCTestCase { func testSuccessfulAsyncResponse() throws { // Setup our objects - let session = NetworkSessionMock() + let session = MockNetworkSession() let manager = NetworkManager(session: session) // Create data and tell the session to always return it @@ -35,7 +35,7 @@ class NetworkManagerTests: XCTestCase { func testSuccessfulSyncResponse() throws { // Setup our objects - let session = NetworkSessionMock() + let session = MockNetworkSession() let manager = NetworkManager(session: session) // Create data and tell the session to always return it @@ -52,7 +52,7 @@ class NetworkManagerTests: XCTestCase { func testFailureAsyncResponse() { // Setup our objects - let session = NetworkSessionMock() + let session = MockNetworkSession() let manager = NetworkManager(session: session) session.error = MASError.noData @@ -73,7 +73,7 @@ class NetworkManagerTests: XCTestCase { func testFailureSyncResponse() { // Setup our objects - let session = NetworkSessionMock() + let session = MockNetworkSession() let manager = NetworkManager(session: session) session.error = MASError.noData