mirror of
https://github.com/mas-cli/mas
synced 2024-11-21 19:23:01 +00:00
Rename *Mock
as Mock*
.
Resolve #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
cc219fe644
commit
880843d8e6
16 changed files with 29 additions and 29 deletions
|
@ -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()
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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] {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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] = []
|
|
@ -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: "",
|
||||
|
|
|
@ -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
|
|
@ -18,7 +18,7 @@ public class SoftwareProductSpec: QuickSpec {
|
|||
MAS.initialize()
|
||||
}
|
||||
describe("software product") {
|
||||
let app = SoftwareProductMock(
|
||||
let app = MockSoftwareProduct(
|
||||
appName: "App",
|
||||
bundleIdentifier: "",
|
||||
bundlePath: "",
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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?
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue