Rename *Mock as Mock*.

Resolve #585

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-25 23:09:31 -04:00
parent cc219fe644
commit 880843d8e6
No known key found for this signature in database
16 changed files with 29 additions and 29 deletions

View file

@ -14,7 +14,7 @@ import Quick
public class HomeSpec: QuickSpec { public class HomeSpec: QuickSpec {
override public func spec() { override public func spec() {
let searcher = MockAppStoreSearcher() let searcher = MockAppStoreSearcher()
let openCommand = OpenSystemCommandMock() let openCommand = MockOpenSystemCommand()
beforeSuite { beforeSuite {
MAS.initialize() MAS.initialize()

View file

@ -13,7 +13,7 @@ import Quick
public class LuckySpec: QuickSpec { public class LuckySpec: QuickSpec {
override public func spec() { 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)) let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession))
beforeSuite { beforeSuite {

View file

@ -15,7 +15,7 @@ import Quick
public class OpenSpec: QuickSpec { public class OpenSpec: QuickSpec {
override public func spec() { override public func spec() {
let searcher = MockAppStoreSearcher() let searcher = MockAppStoreSearcher()
let openCommand = OpenSystemCommandMock() let openCommand = MockOpenSystemCommand()
beforeSuite { beforeSuite {
MAS.initialize() MAS.initialize()

View file

@ -38,7 +38,7 @@ public class OutdatedSpec: QuickSpec {
let mockAppLibrary = MockAppLibrary() let mockAppLibrary = MockAppLibrary()
mockAppLibrary.installedApps.append( mockAppLibrary.installedApps.append(
SoftwareProductMock( MockSoftwareProduct(
appName: mockSearchResult.trackName, appName: mockSearchResult.trackName,
bundleIdentifier: mockSearchResult.bundleId, bundleIdentifier: mockSearchResult.bundleId,
bundlePath: "/Applications/Bandwidth+.app", bundlePath: "/Applications/Bandwidth+.app",

View file

@ -19,7 +19,7 @@ public class UninstallSpec: QuickSpec {
} }
xdescribe("uninstall command") { xdescribe("uninstall command") {
let appID: AppID = 12345 let appID: AppID = 12345
let app = SoftwareProductMock( let app = MockSoftwareProduct(
appName: "Some App", appName: "Some App",
bundleIdentifier: "com.some.app", bundleIdentifier: "com.some.app",
bundlePath: "/tmp/Some.app", bundlePath: "/tmp/Some.app",

View file

@ -14,7 +14,7 @@ import Quick
public class VendorSpec: QuickSpec { public class VendorSpec: QuickSpec {
override public func spec() { override public func spec() {
let searcher = MockAppStoreSearcher() let searcher = MockAppStoreSearcher()
let openCommand = OpenSystemCommandMock() let openCommand = MockOpenSystemCommand()
beforeSuite { beforeSuite {
MAS.initialize() MAS.initialize()

View file

@ -33,7 +33,7 @@ public class ITunesSearchAppStoreSearcherSpec: QuickSpec {
describe("store") { describe("store") {
context("when searched") { context("when searched") {
it("can find slack") { 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)) let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession))
expect { expect {
@ -46,7 +46,7 @@ public class ITunesSearchAppStoreSearcherSpec: QuickSpec {
context("when lookup used") { context("when lookup used") {
it("can find slack") { it("can find slack") {
let appID: AppID = 803_453_959 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)) let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession))
var result: SearchResult? var result: SearchResult?

View file

@ -13,7 +13,7 @@ import Quick
public class SoftwareMapAppLibrarySpec: QuickSpec { public class SoftwareMapAppLibrarySpec: QuickSpec {
override public func spec() { override public func spec() {
let library = SoftwareMapAppLibrary(softwareMap: SoftwareMapMock(products: apps)) let library = SoftwareMapAppLibrary(softwareMap: MockSoftwareMap(products: apps))
beforeSuite { beforeSuite {
MAS.initialize() MAS.initialize()
@ -31,7 +31,7 @@ public class SoftwareMapAppLibrarySpec: QuickSpec {
} }
// MARK: - Test Data // MARK: - Test Data
let myApp = SoftwareProductMock( let myApp = MockSoftwareProduct(
appName: "MyApp", appName: "MyApp",
bundleIdentifier: "com.example", bundleIdentifier: "com.example",
bundlePath: "/Applications/MyApp.app", bundlePath: "/Applications/MyApp.app",
@ -41,8 +41,8 @@ let myApp = SoftwareProductMock(
var apps: [SoftwareProduct] = [myApp] var apps: [SoftwareProduct] = [myApp]
// MARK: - SoftwareMapMock // MARK: - MockSoftwareMap
struct SoftwareMapMock: SoftwareMap { struct MockSoftwareMap: SoftwareMap {
var products: [SoftwareProduct] = [] var products: [SoftwareProduct] = []
func allSoftwareProducts() -> [SoftwareProduct] { func allSoftwareProducts() -> [SoftwareProduct] {

View file

@ -26,7 +26,7 @@ extension Bundle {
static func url(for fileName: String) -> URL? { static func url(for fileName: String) -> URL? {
// The Swift Package Manager places resources in a separate bundle from the executable. // 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 // 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 .bundleURL
.deletingLastPathComponent() .deletingLastPathComponent()
.appendingPathComponent("mas_masTests.bundle") .appendingPathComponent("mas_masTests.bundle")

View file

@ -1,5 +1,5 @@
// //
// OpenSystemCommandMock.swift // MockOpenSystemCommand.swift
// masTests // masTests
// //
// Created by Ben Chatelain on 1/4/19. // Created by Ben Chatelain on 1/4/19.
@ -10,7 +10,7 @@ import Foundation
@testable import mas @testable import mas
class OpenSystemCommandMock: ExternalCommand { class MockOpenSystemCommand: ExternalCommand {
// Stub out protocol logic // Stub out protocol logic
var succeeded = true var succeeded = true
var arguments: [String] = [] var arguments: [String] = []

View file

@ -28,7 +28,7 @@ public class AppListFormatterSpec: QuickSpec {
expect(format(products)).to(beEmpty()) expect(format(products)).to(beEmpty())
} }
it("can format a single product") { it("can format a single product") {
let product = SoftwareProductMock( let product = MockSoftwareProduct(
appName: "Awesome App", appName: "Awesome App",
bundleIdentifier: "", bundleIdentifier: "",
bundlePath: "", bundlePath: "",
@ -39,14 +39,14 @@ public class AppListFormatterSpec: QuickSpec {
} }
it("can format two products") { it("can format two products") {
products = [ products = [
SoftwareProductMock( MockSoftwareProduct(
appName: "Awesome App", appName: "Awesome App",
bundleIdentifier: "", bundleIdentifier: "",
bundlePath: "", bundlePath: "",
bundleVersion: "19.2.1", bundleVersion: "19.2.1",
itemIdentifier: 12345 itemIdentifier: 12345
), ),
SoftwareProductMock( MockSoftwareProduct(
appName: "Even Better App", appName: "Even Better App",
bundleIdentifier: "", bundleIdentifier: "",
bundlePath: "", bundlePath: "",

View file

@ -1,5 +1,5 @@
// //
// SoftwareProductMock.swift // MockSoftwareProduct.swift
// masTests // masTests
// //
// Created by Ben Chatelain on 12/27/18. // Created by Ben Chatelain on 12/27/18.
@ -10,7 +10,7 @@ import Foundation
@testable import mas @testable import mas
struct SoftwareProductMock: SoftwareProduct { struct MockSoftwareProduct: SoftwareProduct {
var appName: String var appName: String
var bundleIdentifier: String var bundleIdentifier: String
var bundlePath: String var bundlePath: String

View file

@ -18,7 +18,7 @@ public class SoftwareProductSpec: QuickSpec {
MAS.initialize() MAS.initialize()
} }
describe("software product") { describe("software product") {
let app = SoftwareProductMock( let app = MockSoftwareProduct(
appName: "App", appName: "App",
bundleIdentifier: "", bundleIdentifier: "",
bundlePath: "", bundlePath: "",

View file

@ -1,5 +1,5 @@
// //
// NetworkSessionMockFromFile.swift // MockFromFileNetworkSession.swift
// masTests // masTests
// //
// Created by Ben Chatelain on 2019-01-05. // Created by Ben Chatelain on 2019-01-05.
@ -10,7 +10,7 @@ import Foundation
import PromiseKit import PromiseKit
/// Mock NetworkSession for testing with saved JSON response payload files. /// 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. /// Path to response payload file relative to test bundle.
private let responseFile: String private let responseFile: String

View file

@ -1,5 +1,5 @@
// //
// NetworkSessionMock // MockNetworkSession
// masTests // masTests
// //
// Created by Ben Chatelain on 11/13/18. // Created by Ben Chatelain on 11/13/18.
@ -12,7 +12,7 @@ import PromiseKit
@testable import mas @testable import mas
/// Mock NetworkSession for testing. /// Mock NetworkSession for testing.
class NetworkSessionMock: NetworkSession { class MockNetworkSession: NetworkSession {
// Properties that enable us to set exactly what data or error // Properties that enable us to set exactly what data or error
// we want our mocked URLSession to return for any request. // we want our mocked URLSession to return for any request.
var data: Data? var data: Data?

View file

@ -18,7 +18,7 @@ class NetworkManagerTests: XCTestCase {
func testSuccessfulAsyncResponse() throws { func testSuccessfulAsyncResponse() throws {
// Setup our objects // Setup our objects
let session = NetworkSessionMock() let session = MockNetworkSession()
let manager = NetworkManager(session: session) let manager = NetworkManager(session: session)
// Create data and tell the session to always return it // Create data and tell the session to always return it
@ -35,7 +35,7 @@ class NetworkManagerTests: XCTestCase {
func testSuccessfulSyncResponse() throws { func testSuccessfulSyncResponse() throws {
// Setup our objects // Setup our objects
let session = NetworkSessionMock() let session = MockNetworkSession()
let manager = NetworkManager(session: session) let manager = NetworkManager(session: session)
// Create data and tell the session to always return it // Create data and tell the session to always return it
@ -52,7 +52,7 @@ class NetworkManagerTests: XCTestCase {
func testFailureAsyncResponse() { func testFailureAsyncResponse() {
// Setup our objects // Setup our objects
let session = NetworkSessionMock() let session = MockNetworkSession()
let manager = NetworkManager(session: session) let manager = NetworkManager(session: session)
session.error = MASError.noData session.error = MASError.noData
@ -73,7 +73,7 @@ class NetworkManagerTests: XCTestCase {
func testFailureSyncResponse() { func testFailureSyncResponse() {
// Setup our objects // Setup our objects
let session = NetworkSessionMock() let session = MockNetworkSession()
let manager = NetworkManager(session: session) let manager = NetworkManager(session: session)
session.error = MASError.noData session.error = MASError.noData