From 3a5593c12d2857c5d37668effb5ecbb95dbca8d5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:14:14 -0400 Subject: [PATCH 1/9] Rename `*accountId` & `username` as `*appleID`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/AppStore/ISStoreAccount.swift | 8 ++++---- Sources/mas/Commands/SignIn.swift | 4 ++-- Sources/mas/Errors/MASError.swift | 6 +++--- Tests/masTests/Errors/MASErrorTestCase.swift | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/mas/AppStore/ISStoreAccount.swift b/Sources/mas/AppStore/ISStoreAccount.swift index ecb3313..56b7bd6 100644 --- a/Sources/mas/AppStore/ISStoreAccount.swift +++ b/Sources/mas/AppStore/ISStoreAccount.swift @@ -32,7 +32,7 @@ extension ISStoreAccount: StoreAccount { return .value(CKAccountStore.shared().primaryAccount) } - static func signIn(username: String, password: String, systemDialog: Bool) -> Promise { + static func signIn(appleID: String, password: String, systemDialog: Bool) -> Promise { // swift-format-ignore: UseEarlyExits if #available(macOS 10.13, *) { // Signing in is no longer possible as of High Sierra. @@ -44,7 +44,7 @@ extension ISStoreAccount: StoreAccount { primaryAccount .then { account -> Promise in if account.isSignedIn { - return Promise(error: MASError.alreadySignedIn(asAccountId: account.identifier)) + return Promise(error: MASError.alreadySignedIn(asAppleID: account.identifier)) } let password = @@ -57,7 +57,7 @@ extension ISStoreAccount: StoreAccount { } let context = ISAuthenticationContext(accountID: 0) - context.appleIDOverride = username + context.appleIDOverride = appleID let signInPromise = Promise { seal in @@ -77,7 +77,7 @@ extension ISStoreAccount: StoreAccount { } context.demoMode = true - context.demoAccountName = username + context.demoAccountName = appleID context.demoAccountPassword = password context.demoAutologinMode = true diff --git a/Sources/mas/Commands/SignIn.swift b/Sources/mas/Commands/SignIn.swift index ea332a3..aaa4a96 100644 --- a/Sources/mas/Commands/SignIn.swift +++ b/Sources/mas/Commands/SignIn.swift @@ -19,14 +19,14 @@ extension Mas { @Flag(help: "Complete login with graphical dialog") var dialog = false @Argument(help: "Apple ID") - var username: String + var appleID: String @Argument(help: "Password") var password: String = "" /// Runs the command. func run() throws { do { - _ = try ISStoreAccount.signIn(username: username, password: password, systemDialog: dialog).wait() + _ = try ISStoreAccount.signIn(appleID: appleID, password: password, systemDialog: dialog).wait() } catch { throw error as? MASError ?? MASError.signInFailed(error: error as NSError) } diff --git a/Sources/mas/Errors/MASError.swift b/Sources/mas/Errors/MASError.swift index 7aea57f..1d31b7f 100644 --- a/Sources/mas/Errors/MASError.swift +++ b/Sources/mas/Errors/MASError.swift @@ -18,7 +18,7 @@ enum MASError: Error, Equatable { case notSignedIn case noPasswordProvided case signInFailed(error: NSError?) - case alreadySignedIn(asAccountId: String) + case alreadySignedIn(asAppleID: String) case purchaseFailed(error: NSError?) case downloadFailed(error: NSError?) @@ -63,8 +63,8 @@ extension MASError: CustomStringConvertible { return "Sign in failed: \(error.localizedDescription)" } return "Sign in failed" - case .alreadySignedIn(let accountId): - return "Already signed in as \(accountId)" + case .alreadySignedIn(let appleID): + return "Already signed in as \(appleID)" case .purchaseFailed(let error): if let error { return "Download request failed: \(error.localizedDescription)" diff --git a/Tests/masTests/Errors/MASErrorTestCase.swift b/Tests/masTests/Errors/MASErrorTestCase.swift index 47c83d6..15cecfc 100644 --- a/Tests/masTests/Errors/MASErrorTestCase.swift +++ b/Tests/masTests/Errors/MASErrorTestCase.swift @@ -59,7 +59,7 @@ class MASErrorTestCase: XCTestCase { } func testAlreadySignedIn() { - error = .alreadySignedIn(asAccountId: "person@example.com") + error = .alreadySignedIn(asAppleID: "person@example.com") XCTAssertEqual(error.description, "Already signed in as person@example.com") } From 0e49da7bf1fc5eed50ab6308fb2edf93961d76f2 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:49:21 -0400 Subject: [PATCH 2/9] Rename `*bundleId` as `*bundleID`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Controllers/MasAppLibrary.swift | 8 ++++---- Tests/masTests/Controllers/MasAppLibrarySpec.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/mas/Controllers/MasAppLibrary.swift b/Sources/mas/Controllers/MasAppLibrary.swift index 8e27760..d9e2f7d 100644 --- a/Sources/mas/Controllers/MasAppLibrary.swift +++ b/Sources/mas/Controllers/MasAppLibrary.swift @@ -28,10 +28,10 @@ class MasAppLibrary: AppLibrary { /// Finds an app using a bundle identifier. /// - /// - Parameter bundleId: Bundle identifier of app. - /// - Returns: Software Product of app if found; nil otherwise. - func installedApp(forBundleId bundleId: String) -> SoftwareProduct? { - softwareMap.product(for: bundleId) + /// - Parameter bundleID: Bundle identifier of app. + /// - Returns: `SoftwareProduct` for app if found; `nil` otherwise. + func installedApp(forBundleID bundleID: String) -> SoftwareProduct? { + softwareMap.product(for: bundleID) } /// Uninstalls all apps located at any of the elements of `appPaths`. diff --git a/Tests/masTests/Controllers/MasAppLibrarySpec.swift b/Tests/masTests/Controllers/MasAppLibrarySpec.swift index fbb85fb..69c2cc9 100644 --- a/Tests/masTests/Controllers/MasAppLibrarySpec.swift +++ b/Tests/masTests/Controllers/MasAppLibrarySpec.swift @@ -24,7 +24,7 @@ public class MasAppLibrarySpec: QuickSpec { expect(library.installedApps.first!.appName) == myApp.appName } it("can locate an app by bundle id") { - expect(library.installedApp(forBundleId: "com.example")!.bundleIdentifier) == myApp.bundleIdentifier + expect(library.installedApp(forBundleID: "com.example")!.bundleIdentifier) == myApp.bundleIdentifier } } } From 0b11f3737c92148e47ecafb40b22571cb276988e Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:04:06 -0400 Subject: [PATCH 3/9] Rename some uses of `appName` as `searchTerm`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Commands/Lucky.swift | 4 ++-- Sources/mas/Commands/Search.swift | 4 ++-- Sources/mas/Controllers/StoreSearch.swift | 2 +- Tests/masTests/Controllers/StoreSearchMock.swift | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/mas/Commands/Lucky.swift b/Sources/mas/Commands/Lucky.swift index 296dde7..886b864 100644 --- a/Sources/mas/Commands/Lucky.swift +++ b/Sources/mas/Commands/Lucky.swift @@ -21,7 +21,7 @@ extension Mas { @Flag(help: "force reinstall") var force = false @Argument(help: "the app name to install") - var appName: String + var searchTerm: String /// Runs the command. func run() throws { @@ -32,7 +32,7 @@ extension Mas { var appID: AppID? do { - let results = try storeSearch.search(for: appName).wait() + let results = try storeSearch.search(for: searchTerm).wait() guard let result = results.first else { printError("No results found") throw MASError.noSearchResultsFound diff --git a/Sources/mas/Commands/Search.swift b/Sources/mas/Commands/Search.swift index 79ef211..6e6c07e 100644 --- a/Sources/mas/Commands/Search.swift +++ b/Sources/mas/Commands/Search.swift @@ -20,7 +20,7 @@ extension Mas { @Flag(help: "Show price of found apps") var price = false @Argument(help: "the app name to search") - var appName: String + var searchTerm: String func run() throws { try run(storeSearch: MasStoreSearch()) @@ -28,7 +28,7 @@ extension Mas { func run(storeSearch: StoreSearch) throws { do { - let results = try storeSearch.search(for: appName).wait() + let results = try storeSearch.search(for: searchTerm).wait() if results.isEmpty { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Controllers/StoreSearch.swift b/Sources/mas/Controllers/StoreSearch.swift index 166e7fd..0b8194c 100644 --- a/Sources/mas/Controllers/StoreSearch.swift +++ b/Sources/mas/Controllers/StoreSearch.swift @@ -12,7 +12,7 @@ import PromiseKit /// Protocol for searching the MAS catalog. protocol StoreSearch { func lookup(appID: AppID) -> Promise - func search(for appName: String) -> Promise<[SearchResult]> + func search(for searchTerm: String) -> Promise<[SearchResult]> } enum Entity: String { diff --git a/Tests/masTests/Controllers/StoreSearchMock.swift b/Tests/masTests/Controllers/StoreSearchMock.swift index 938c2b0..4b5143d 100644 --- a/Tests/masTests/Controllers/StoreSearchMock.swift +++ b/Tests/masTests/Controllers/StoreSearchMock.swift @@ -13,8 +13,8 @@ import PromiseKit class StoreSearchMock: StoreSearch { var apps: [AppID: SearchResult] = [:] - func search(for appName: String) -> Promise<[SearchResult]> { - .value(apps.filter { $1.trackName.contains(appName) }.map { $1 }) + func search(for searchTerm: String) -> Promise<[SearchResult]> { + .value(apps.filter { $1.trackName.contains(searchTerm) }.map { $1 }) } func lookup(appID: AppID) -> Promise { From 59a642590a347c2afd890566f457c84704a2ea93 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:08:50 -0400 Subject: [PATCH 4/9] Rename some uses of `*Url` as `*URL`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Controllers/MasStoreSearch.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/mas/Controllers/MasStoreSearch.swift b/Sources/mas/Controllers/MasStoreSearch.swift index 2dc7ff4..e7bb192 100644 --- a/Sources/mas/Controllers/MasStoreSearch.swift +++ b/Sources/mas/Controllers/MasStoreSearch.swift @@ -77,12 +77,12 @@ class MasStoreSearch: StoreSearch { return .value(nil) } - guard let pageUrl = URL(string: result.trackViewUrl) else { + guard let pageURL = URL(string: result.trackViewUrl) else { return .value(result) } return firstly { - self.scrapeAppStoreVersion(pageUrl) + self.scrapeAppStoreVersion(pageURL) } .map { pageVersion in guard let pageVersion, @@ -120,9 +120,9 @@ class MasStoreSearch: StoreSearch { /// Scrape the app version from the App Store webpage at the given URL. /// /// App Store webpages frequently report a version that is newer than what is reported by the iTunes Search API. - private func scrapeAppStoreVersion(_ pageUrl: URL) -> Promise { + private func scrapeAppStoreVersion(_ pageURL: URL) -> Promise { firstly { - networkManager.loadData(from: pageUrl) + networkManager.loadData(from: pageURL) } .map { data in guard let html = String(data: data, encoding: .utf8), From 6bf5696093a89f86ab0450ab05a2fa7619f817dc Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:17:23 -0400 Subject: [PATCH 5/9] Chop down multiline `guard` clauses. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/AppStore/Downloader.swift | 3 ++- Sources/mas/AppStore/PurchaseDownloadObserver.swift | 6 ++++-- Sources/mas/Controllers/MasStoreSearch.swift | 6 ++++-- Sources/mas/Models/SoftwareProduct.swift | 3 ++- Tests/masTests/Extensions/Bundle+JSON.swift | 3 ++- docs/sample.swift | 11 +++++++---- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Sources/mas/AppStore/Downloader.swift b/Sources/mas/AppStore/Downloader.swift index bb09f3d..6435ff6 100644 --- a/Sources/mas/AppStore/Downloader.swift +++ b/Sources/mas/AppStore/Downloader.swift @@ -47,7 +47,8 @@ private func downloadWithRetries(_ appID: AppID, purchase: Bool = false, attempt } // If the download failed due to network issues, try again. Otherwise, fail immediately. - guard case MASError.downloadFailed(let downloadError) = error, + guard + case MASError.downloadFailed(let downloadError) = error, case NSURLErrorDomain = downloadError?.domain else { throw error diff --git a/Sources/mas/AppStore/PurchaseDownloadObserver.swift b/Sources/mas/AppStore/PurchaseDownloadObserver.swift index c6709cf..30b968c 100644 --- a/Sources/mas/AppStore/PurchaseDownloadObserver.swift +++ b/Sources/mas/AppStore/PurchaseDownloadObserver.swift @@ -20,7 +20,8 @@ class PurchaseDownloadObserver: NSObject, CKDownloadQueueObserver { } func downloadQueue(_ queue: CKDownloadQueue, statusChangedFor download: SSDownload) { - guard download.metadata.itemIdentifier == purchase.itemIdentifier, + guard + download.metadata.itemIdentifier == purchase.itemIdentifier, let status = download.status else { return @@ -42,7 +43,8 @@ class PurchaseDownloadObserver: NSObject, CKDownloadQueueObserver { } func downloadQueue(_: CKDownloadQueue, changedWithRemoval download: SSDownload) { - guard download.metadata.itemIdentifier == purchase.itemIdentifier, + guard + download.metadata.itemIdentifier == purchase.itemIdentifier, let status = download.status else { return diff --git a/Sources/mas/Controllers/MasStoreSearch.swift b/Sources/mas/Controllers/MasStoreSearch.swift index e7bb192..a046778 100644 --- a/Sources/mas/Controllers/MasStoreSearch.swift +++ b/Sources/mas/Controllers/MasStoreSearch.swift @@ -85,7 +85,8 @@ class MasStoreSearch: StoreSearch { self.scrapeAppStoreVersion(pageURL) } .map { pageVersion in - guard let pageVersion, + guard + let pageVersion, let searchVersion = Version(tolerant: result.version), pageVersion > searchVersion else { @@ -125,7 +126,8 @@ class MasStoreSearch: StoreSearch { networkManager.loadData(from: pageURL) } .map { data in - guard let html = String(data: data, encoding: .utf8), + guard + let html = String(data: data, encoding: .utf8), let capture = Self.appVersionExpression.firstMatch(in: html)?.captures[0], let version = Version(tolerant: capture) else { diff --git a/Sources/mas/Models/SoftwareProduct.swift b/Sources/mas/Models/SoftwareProduct.swift index 7b882c5..29c393f 100644 --- a/Sources/mas/Models/SoftwareProduct.swift +++ b/Sources/mas/Models/SoftwareProduct.swift @@ -45,7 +45,8 @@ extension SoftwareProduct { // The App Store does not enforce semantic versioning, but we assume most apps follow versioning // schemes that increase numerically over time. - guard let semanticBundleVersion = Version(tolerant: bundleVersion), + guard + let semanticBundleVersion = Version(tolerant: bundleVersion), let semanticAppStoreVersion = Version(tolerant: storeApp.version) else { // If a version string can't be parsed as a Semantic Version, our best effort is to check for diff --git a/Tests/masTests/Extensions/Bundle+JSON.swift b/Tests/masTests/Extensions/Bundle+JSON.swift index 3c9628c..d74c2c0 100644 --- a/Tests/masTests/Extensions/Bundle+JSON.swift +++ b/Tests/masTests/Extensions/Bundle+JSON.swift @@ -30,7 +30,8 @@ extension Bundle { .bundleURL .deletingLastPathComponent() .appendingPathComponent("mas_masTests.bundle") - guard let bundle = Bundle(url: bundleURL), + guard + let bundle = Bundle(url: bundleURL), let url = bundle.url(for: fileName) else { fatalError("Unable to load file \(fileName)") diff --git a/docs/sample.swift b/docs/sample.swift index fd7091e..17fc5d4 100644 --- a/docs/sample.swift +++ b/docs/sample.swift @@ -90,11 +90,14 @@ private extension MyClass { guard let singleTest = somethingFailable() else { return } guard statementThatShouldBeTrue else { return } -// If there is one long expression to guard or multiple expressions -// move else to next line -guard let oneItem = somethingFailable(), +// If a guard clause requires multiple lines, chop down, then start `else` new line +// In this case, always chop down else clause. +guard + let oneItem = somethingFailable(), let secondItem = somethingFailable2() -else { return } +else { + return +} // If the return in else is long, move to next line guard let something = somethingFailable() else { From ab22e22ace31d269da36a0afe8bea2b9bec2ac33 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:21:19 -0400 Subject: [PATCH 6/9] Rename `Mas` as `MAS`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Commands/Account.swift | 2 +- Sources/mas/Commands/Home.swift | 2 +- Sources/mas/Commands/Info.swift | 2 +- Sources/mas/Commands/Install.swift | 2 +- Sources/mas/Commands/List.swift | 2 +- Sources/mas/Commands/Lucky.swift | 2 +- Sources/mas/Commands/Open.swift | 2 +- Sources/mas/Commands/Outdated.swift | 2 +- Sources/mas/Commands/Purchase.swift | 2 +- Sources/mas/Commands/Reset.swift | 2 +- Sources/mas/Commands/Search.swift | 2 +- Sources/mas/Commands/SignIn.swift | 2 +- Sources/mas/Commands/SignOut.swift | 2 +- Sources/mas/Commands/Uninstall.swift | 2 +- Sources/mas/Commands/Upgrade.swift | 2 +- Sources/mas/Commands/Vendor.swift | 2 +- Sources/mas/Commands/Version.swift | 2 +- Sources/mas/{Mas.swift => MAS.swift} | 4 ++-- Tests/masTests/Commands/AccountSpec.swift | 4 ++-- Tests/masTests/Commands/HomeSpec.swift | 8 ++++---- Tests/masTests/Commands/InfoSpec.swift | 8 ++++---- Tests/masTests/Commands/InstallSpec.swift | 4 ++-- Tests/masTests/Commands/ListSpec.swift | 4 ++-- Tests/masTests/Commands/LuckySpec.swift | 4 ++-- Tests/masTests/Commands/OpenSpec.swift | 10 +++++----- Tests/masTests/Commands/OutdatedSpec.swift | 4 ++-- Tests/masTests/Commands/PurchaseSpec.swift | 4 ++-- Tests/masTests/Commands/ResetSpec.swift | 4 ++-- Tests/masTests/Commands/SearchSpec.swift | 6 +++--- Tests/masTests/Commands/SignInSpec.swift | 4 ++-- Tests/masTests/Commands/SignOutSpec.swift | 4 ++-- Tests/masTests/Commands/UninstallSpec.swift | 6 +++--- Tests/masTests/Commands/UpgradeSpec.swift | 4 ++-- Tests/masTests/Commands/VendorSpec.swift | 8 ++++---- Tests/masTests/Commands/VersionSpec.swift | 4 ++-- Tests/masTests/Controllers/MasAppLibrarySpec.swift | 2 +- Tests/masTests/Controllers/MasStoreSearchSpec.swift | 2 +- Tests/masTests/Errors/MASErrorTestCase.swift | 2 +- .../ExternalCommands/OpenSystemCommandSpec.swift | 2 +- Tests/masTests/Formatters/AppListFormatterSpec.swift | 2 +- .../Formatters/SearchResultFormatterSpec.swift | 2 +- Tests/masTests/Models/SearchResultListSpec.swift | 2 +- Tests/masTests/Models/SearchResultSpec.swift | 2 +- Tests/masTests/Models/SoftwareProductSpec.swift | 2 +- Tests/masTests/Network/NetworkManagerTests.swift | 2 +- 45 files changed, 74 insertions(+), 74 deletions(-) rename Sources/mas/{Mas.swift => MAS.swift} (97%) diff --git a/Sources/mas/Commands/Account.swift b/Sources/mas/Commands/Account.swift index bd172f6..a9f90a6 100644 --- a/Sources/mas/Commands/Account.swift +++ b/Sources/mas/Commands/Account.swift @@ -9,7 +9,7 @@ import ArgumentParser import StoreFoundation -extension Mas { +extension MAS { struct Account: ParsableCommand { static let configuration = CommandConfiguration( abstract: "Prints the primary account Apple ID" diff --git a/Sources/mas/Commands/Home.swift b/Sources/mas/Commands/Home.swift index 18a7a53..d9d3b23 100644 --- a/Sources/mas/Commands/Home.swift +++ b/Sources/mas/Commands/Home.swift @@ -8,7 +8,7 @@ import ArgumentParser -extension Mas { +extension MAS { /// Opens app page on MAS Preview. Uses the iTunes Lookup API: /// https://performance-partners.apple.com/search-api struct Home: ParsableCommand { diff --git a/Sources/mas/Commands/Info.swift b/Sources/mas/Commands/Info.swift index ca862d2..e832d20 100644 --- a/Sources/mas/Commands/Info.swift +++ b/Sources/mas/Commands/Info.swift @@ -9,7 +9,7 @@ import ArgumentParser import Foundation -extension Mas { +extension MAS { /// Displays app details. Uses the iTunes Lookup API: /// https://performance-partners.apple.com/search-api struct Info: ParsableCommand { diff --git a/Sources/mas/Commands/Install.swift b/Sources/mas/Commands/Install.swift index 1ba12b0..2b13081 100644 --- a/Sources/mas/Commands/Install.swift +++ b/Sources/mas/Commands/Install.swift @@ -9,7 +9,7 @@ import ArgumentParser import CommerceKit -extension Mas { +extension MAS { /// Installs previously purchased apps from the Mac App Store. struct Install: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Commands/List.swift b/Sources/mas/Commands/List.swift index 492f58c..eb782e2 100644 --- a/Sources/mas/Commands/List.swift +++ b/Sources/mas/Commands/List.swift @@ -8,7 +8,7 @@ import ArgumentParser -extension Mas { +extension MAS { /// Command which lists all installed apps. struct List: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Commands/Lucky.swift b/Sources/mas/Commands/Lucky.swift index 886b864..f2a33c3 100644 --- a/Sources/mas/Commands/Lucky.swift +++ b/Sources/mas/Commands/Lucky.swift @@ -9,7 +9,7 @@ import ArgumentParser import CommerceKit -extension Mas { +extension MAS { /// Command which installs the first search result. /// /// This is handy as many MAS titles can be long with embedded keywords. diff --git a/Sources/mas/Commands/Open.swift b/Sources/mas/Commands/Open.swift index 82e98de..c2369e9 100644 --- a/Sources/mas/Commands/Open.swift +++ b/Sources/mas/Commands/Open.swift @@ -11,7 +11,7 @@ import Foundation private let masScheme = "macappstore" -extension Mas { +extension MAS { /// Opens app page in MAS app. Uses the iTunes Lookup API: /// https://performance-partners.apple.com/search-api struct Open: ParsableCommand { diff --git a/Sources/mas/Commands/Outdated.swift b/Sources/mas/Commands/Outdated.swift index 2164a4b..77325ba 100644 --- a/Sources/mas/Commands/Outdated.swift +++ b/Sources/mas/Commands/Outdated.swift @@ -10,7 +10,7 @@ import ArgumentParser import Foundation import PromiseKit -extension Mas { +extension MAS { /// Command which displays a list of installed apps which have available updates /// ready to be installed from the Mac App Store. struct Outdated: ParsableCommand { diff --git a/Sources/mas/Commands/Purchase.swift b/Sources/mas/Commands/Purchase.swift index 58a7a48..66f4c92 100644 --- a/Sources/mas/Commands/Purchase.swift +++ b/Sources/mas/Commands/Purchase.swift @@ -9,7 +9,7 @@ import ArgumentParser import CommerceKit -extension Mas { +extension MAS { struct Purchase: ParsableCommand { static let configuration = CommandConfiguration( abstract: "Purchase and download free apps from the Mac App Store" diff --git a/Sources/mas/Commands/Reset.swift b/Sources/mas/Commands/Reset.swift index 76a32bd..37ff3e4 100644 --- a/Sources/mas/Commands/Reset.swift +++ b/Sources/mas/Commands/Reset.swift @@ -9,7 +9,7 @@ import ArgumentParser import CommerceKit -extension Mas { +extension MAS { /// Kills several macOS processes as a means to reset the app store. struct Reset: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Commands/Search.swift b/Sources/mas/Commands/Search.swift index 6e6c07e..ef14e1e 100644 --- a/Sources/mas/Commands/Search.swift +++ b/Sources/mas/Commands/Search.swift @@ -8,7 +8,7 @@ import ArgumentParser -extension Mas { +extension MAS { /// Search the Mac App Store using the iTunes Search API. /// /// See - https://performance-partners.apple.com/search-api diff --git a/Sources/mas/Commands/SignIn.swift b/Sources/mas/Commands/SignIn.swift index aaa4a96..c94da79 100644 --- a/Sources/mas/Commands/SignIn.swift +++ b/Sources/mas/Commands/SignIn.swift @@ -9,7 +9,7 @@ import ArgumentParser import StoreFoundation -extension Mas { +extension MAS { struct SignIn: ParsableCommand { static let configuration = CommandConfiguration( commandName: "signin", diff --git a/Sources/mas/Commands/SignOut.swift b/Sources/mas/Commands/SignOut.swift index 3384d8e..1c0d49d 100644 --- a/Sources/mas/Commands/SignOut.swift +++ b/Sources/mas/Commands/SignOut.swift @@ -9,7 +9,7 @@ import ArgumentParser import CommerceKit -extension Mas { +extension MAS { struct SignOut: ParsableCommand { static let configuration = CommandConfiguration( commandName: "signout", diff --git a/Sources/mas/Commands/Uninstall.swift b/Sources/mas/Commands/Uninstall.swift index b73378b..68561c7 100644 --- a/Sources/mas/Commands/Uninstall.swift +++ b/Sources/mas/Commands/Uninstall.swift @@ -9,7 +9,7 @@ import ArgumentParser import Foundation -extension Mas { +extension MAS { /// Command which uninstalls apps managed by the Mac App Store. struct Uninstall: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index 83c4788..079550e 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -10,7 +10,7 @@ import ArgumentParser import Foundation import PromiseKit -extension Mas { +extension MAS { /// Command which upgrades apps with new versions available in the Mac App Store. struct Upgrade: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Commands/Vendor.swift b/Sources/mas/Commands/Vendor.swift index 7380ca0..d3004a1 100644 --- a/Sources/mas/Commands/Vendor.swift +++ b/Sources/mas/Commands/Vendor.swift @@ -8,7 +8,7 @@ import ArgumentParser -extension Mas { +extension MAS { /// Opens vendor's app page in a browser. Uses the iTunes Lookup API: /// https://performance-partners.apple.com/search-api struct Vendor: ParsableCommand { diff --git a/Sources/mas/Commands/Version.swift b/Sources/mas/Commands/Version.swift index 00c0e5b..4493088 100644 --- a/Sources/mas/Commands/Version.swift +++ b/Sources/mas/Commands/Version.swift @@ -8,7 +8,7 @@ import ArgumentParser -extension Mas { +extension MAS { /// Command which displays the version of the mas tool. struct Version: ParsableCommand { static let configuration = CommandConfiguration( diff --git a/Sources/mas/Mas.swift b/Sources/mas/MAS.swift similarity index 97% rename from Sources/mas/Mas.swift rename to Sources/mas/MAS.swift index 89aeacb..aee1262 100644 --- a/Sources/mas/Mas.swift +++ b/Sources/mas/MAS.swift @@ -1,5 +1,5 @@ // -// Mas.swift +// MAS.swift // mas // // Created by Chris Araman on 4/22/21. @@ -11,7 +11,7 @@ import Foundation import PromiseKit @main -struct Mas: ParsableCommand { +struct MAS: ParsableCommand { static let configuration = CommandConfiguration( abstract: "Mac App Store command-line interface", subcommands: [ diff --git a/Tests/masTests/Commands/AccountSpec.swift b/Tests/masTests/Commands/AccountSpec.swift index db220c4..8885916 100644 --- a/Tests/masTests/Commands/AccountSpec.swift +++ b/Tests/masTests/Commands/AccountSpec.swift @@ -15,13 +15,13 @@ import Quick public class AccountSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } // account command disabled since macOS 12 Monterey https://github.com/mas-cli/mas#known-issues describe("Account command") { it("displays active account") { expect { - try Mas.Account.parse([]).run() + try MAS.Account.parse([]).run() } .to(throwError(MASError.notSupported)) } diff --git a/Tests/masTests/Commands/HomeSpec.swift b/Tests/masTests/Commands/HomeSpec.swift index 097855e..46d22f6 100644 --- a/Tests/masTests/Commands/HomeSpec.swift +++ b/Tests/masTests/Commands/HomeSpec.swift @@ -17,7 +17,7 @@ public class HomeSpec: QuickSpec { let openCommand = OpenSystemCommandMock() beforeSuite { - Mas.initialize() + MAS.initialize() } describe("home command") { beforeEach { @@ -25,13 +25,13 @@ public class HomeSpec: QuickSpec { } it("fails to open app with invalid ID") { expect { - try Mas.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try Mas.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -43,7 +43,7 @@ public class HomeSpec: QuickSpec { ) storeSearch.apps[mockResult.trackId] = mockResult expect { - try Mas.Home.parse([String(mockResult.trackId)]) + try MAS.Home.parse([String(mockResult.trackId)]) .run(storeSearch: storeSearch, openCommand: openCommand) return openCommand.arguments } diff --git a/Tests/masTests/Commands/InfoSpec.swift b/Tests/masTests/Commands/InfoSpec.swift index 7271451..400ddb6 100644 --- a/Tests/masTests/Commands/InfoSpec.swift +++ b/Tests/masTests/Commands/InfoSpec.swift @@ -17,7 +17,7 @@ public class InfoSpec: QuickSpec { let storeSearch = StoreSearchMock() beforeSuite { - Mas.initialize() + MAS.initialize() } describe("Info command") { beforeEach { @@ -25,13 +25,13 @@ public class InfoSpec: QuickSpec { } it("fails to open app with invalid ID") { expect { - try Mas.Info.parse(["--", "-999"]).run(storeSearch: storeSearch) + try MAS.Info.parse(["--", "-999"]).run(storeSearch: storeSearch) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try Mas.Info.parse(["999"]).run(storeSearch: storeSearch) + try MAS.Info.parse(["999"]).run(storeSearch: storeSearch) } .to(throwError(MASError.noSearchResultsFound)) } @@ -50,7 +50,7 @@ public class InfoSpec: QuickSpec { storeSearch.apps[mockResult.trackId] = mockResult expect { try captureStream(stdout) { - try Mas.Info.parse([String(mockResult.trackId)]).run(storeSearch: storeSearch) + try MAS.Info.parse([String(mockResult.trackId)]).run(storeSearch: storeSearch) } } == """ diff --git a/Tests/masTests/Commands/InstallSpec.swift b/Tests/masTests/Commands/InstallSpec.swift index 4baeead..88ad308 100644 --- a/Tests/masTests/Commands/InstallSpec.swift +++ b/Tests/masTests/Commands/InstallSpec.swift @@ -14,12 +14,12 @@ import Quick public class InstallSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } xdescribe("install command") { xit("installs apps") { expect { - try Mas.Install.parse([]).run(appLibrary: AppLibraryMock()) + try MAS.Install.parse([]).run(appLibrary: AppLibraryMock()) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/ListSpec.swift b/Tests/masTests/Commands/ListSpec.swift index 7388e80..c72bdf6 100644 --- a/Tests/masTests/Commands/ListSpec.swift +++ b/Tests/masTests/Commands/ListSpec.swift @@ -15,13 +15,13 @@ import Quick public class ListSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("list command") { it("lists apps") { expect { try captureStream(stderr) { - try Mas.List.parse([]).run(appLibrary: AppLibraryMock()) + try MAS.List.parse([]).run(appLibrary: AppLibraryMock()) } } == "Error: No installed apps found\n" diff --git a/Tests/masTests/Commands/LuckySpec.swift b/Tests/masTests/Commands/LuckySpec.swift index 4e373c2..fa73ab9 100644 --- a/Tests/masTests/Commands/LuckySpec.swift +++ b/Tests/masTests/Commands/LuckySpec.swift @@ -17,12 +17,12 @@ public class LuckySpec: QuickSpec { let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession)) beforeSuite { - Mas.initialize() + MAS.initialize() } xdescribe("lucky command") { xit("installs the first app matching a search") { expect { - try Mas.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), storeSearch: storeSearch) + try MAS.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), storeSearch: storeSearch) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/OpenSpec.swift b/Tests/masTests/Commands/OpenSpec.swift index 13693fb..23b7119 100644 --- a/Tests/masTests/Commands/OpenSpec.swift +++ b/Tests/masTests/Commands/OpenSpec.swift @@ -18,7 +18,7 @@ public class OpenSpec: QuickSpec { let openCommand = OpenSystemCommandMock() beforeSuite { - Mas.initialize() + MAS.initialize() } describe("open command") { beforeEach { @@ -26,13 +26,13 @@ public class OpenSpec: QuickSpec { } it("fails to open app with invalid ID") { expect { - try Mas.Open.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try Mas.Open.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -44,7 +44,7 @@ public class OpenSpec: QuickSpec { ) storeSearch.apps[mockResult.trackId] = mockResult expect { - try Mas.Open.parse([mockResult.trackId.description]) + try MAS.Open.parse([mockResult.trackId.description]) .run(storeSearch: storeSearch, openCommand: openCommand) return openCommand.arguments } @@ -52,7 +52,7 @@ public class OpenSpec: QuickSpec { } it("just opens MAS if no app specified") { expect { - try Mas.Open.parse([]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse([]).run(storeSearch: storeSearch, openCommand: openCommand) return openCommand.arguments } == ["macappstore://"] diff --git a/Tests/masTests/Commands/OutdatedSpec.swift b/Tests/masTests/Commands/OutdatedSpec.swift index d47b067..72e0f50 100644 --- a/Tests/masTests/Commands/OutdatedSpec.swift +++ b/Tests/masTests/Commands/OutdatedSpec.swift @@ -15,7 +15,7 @@ import Quick public class OutdatedSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("outdated command") { it("displays apps with pending updates") { @@ -48,7 +48,7 @@ public class OutdatedSpec: QuickSpec { ) expect { try captureStream(stdout) { - try Mas.Outdated.parse([]).run(appLibrary: mockAppLibrary, storeSearch: mockStoreSearch) + try MAS.Outdated.parse([]).run(appLibrary: mockAppLibrary, storeSearch: mockStoreSearch) } } == "490461369 Bandwidth+ (1.27 -> 1.28)\n" diff --git a/Tests/masTests/Commands/PurchaseSpec.swift b/Tests/masTests/Commands/PurchaseSpec.swift index 51f84f5..798a5e8 100644 --- a/Tests/masTests/Commands/PurchaseSpec.swift +++ b/Tests/masTests/Commands/PurchaseSpec.swift @@ -14,12 +14,12 @@ import Quick public class PurchaseSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } xdescribe("purchase command") { xit("purchases apps") { expect { - try Mas.Purchase.parse(["999"]).run(appLibrary: AppLibraryMock()) + try MAS.Purchase.parse(["999"]).run(appLibrary: AppLibraryMock()) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/ResetSpec.swift b/Tests/masTests/Commands/ResetSpec.swift index ca39e2b..96e8adb 100644 --- a/Tests/masTests/Commands/ResetSpec.swift +++ b/Tests/masTests/Commands/ResetSpec.swift @@ -14,12 +14,12 @@ import Quick public class ResetSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("reset command") { it("resets the App Store state") { expect { - try Mas.Reset.parse([]).run() + try MAS.Reset.parse([]).run() } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/SearchSpec.swift b/Tests/masTests/Commands/SearchSpec.swift index 91a3a45..3984fa1 100644 --- a/Tests/masTests/Commands/SearchSpec.swift +++ b/Tests/masTests/Commands/SearchSpec.swift @@ -17,7 +17,7 @@ public class SearchSpec: QuickSpec { let storeSearch = StoreSearchMock() beforeSuite { - Mas.initialize() + MAS.initialize() } describe("search command") { beforeEach { @@ -33,14 +33,14 @@ public class SearchSpec: QuickSpec { storeSearch.apps[mockResult.trackId] = mockResult expect { try captureStream(stdout) { - try Mas.Search.parse(["slack"]).run(storeSearch: storeSearch) + try MAS.Search.parse(["slack"]).run(storeSearch: storeSearch) } } == " 1111 slack (0.0)\n" } it("fails when searching for nonexistent app") { expect { - try Mas.Search.parse(["nonexistent"]).run(storeSearch: storeSearch) + try MAS.Search.parse(["nonexistent"]).run(storeSearch: storeSearch) } .to(throwError(MASError.noSearchResultsFound)) } diff --git a/Tests/masTests/Commands/SignInSpec.swift b/Tests/masTests/Commands/SignInSpec.swift index f7f5d33..ceea01c 100644 --- a/Tests/masTests/Commands/SignInSpec.swift +++ b/Tests/masTests/Commands/SignInSpec.swift @@ -15,13 +15,13 @@ import Quick public class SignInSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } // account command disabled since macOS 10.13 High Sierra https://github.com/mas-cli/mas#known-issues describe("signin command") { it("signs in") { expect { - try Mas.SignIn.parse(["", ""]).run() + try MAS.SignIn.parse(["", ""]).run() } .to(throwError(MASError.notSupported)) } diff --git a/Tests/masTests/Commands/SignOutSpec.swift b/Tests/masTests/Commands/SignOutSpec.swift index a5b5466..7aeaa01 100644 --- a/Tests/masTests/Commands/SignOutSpec.swift +++ b/Tests/masTests/Commands/SignOutSpec.swift @@ -14,12 +14,12 @@ import Quick public class SignOutSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("signout command") { it("signs out") { expect { - try Mas.SignOut.parse([]).run() + try MAS.SignOut.parse([]).run() } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/UninstallSpec.swift b/Tests/masTests/Commands/UninstallSpec.swift index 69cb44e..fbc3c1a 100644 --- a/Tests/masTests/Commands/UninstallSpec.swift +++ b/Tests/masTests/Commands/UninstallSpec.swift @@ -15,7 +15,7 @@ import Quick public class UninstallSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } xdescribe("uninstall command") { let appID: AppID = 12345 @@ -29,7 +29,7 @@ public class UninstallSpec: QuickSpec { let mockLibrary = AppLibraryMock() context("dry run") { - let uninstall = try! Mas.Uninstall.parse(["--dry-run", String(appID)]) + let uninstall = try! MAS.Uninstall.parse(["--dry-run", String(appID)]) beforeEach { mockLibrary.reset() @@ -51,7 +51,7 @@ public class UninstallSpec: QuickSpec { } } context("wet run") { - let uninstall = try! Mas.Uninstall.parse([String(appID)]) + let uninstall = try! MAS.Uninstall.parse([String(appID)]) beforeEach { mockLibrary.reset() diff --git a/Tests/masTests/Commands/UpgradeSpec.swift b/Tests/masTests/Commands/UpgradeSpec.swift index 5c104bb..585e751 100644 --- a/Tests/masTests/Commands/UpgradeSpec.swift +++ b/Tests/masTests/Commands/UpgradeSpec.swift @@ -15,13 +15,13 @@ import Quick public class UpgradeSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("upgrade command") { it("finds no upgrades") { expect { try captureStream(stderr) { - try Mas.Upgrade.parse([]) + try MAS.Upgrade.parse([]) .run(appLibrary: AppLibraryMock(), storeSearch: StoreSearchMock()) } } diff --git a/Tests/masTests/Commands/VendorSpec.swift b/Tests/masTests/Commands/VendorSpec.swift index 624f3a3..a73d1e1 100644 --- a/Tests/masTests/Commands/VendorSpec.swift +++ b/Tests/masTests/Commands/VendorSpec.swift @@ -17,7 +17,7 @@ public class VendorSpec: QuickSpec { let openCommand = OpenSystemCommandMock() beforeSuite { - Mas.initialize() + MAS.initialize() } describe("vendor command") { beforeEach { @@ -25,13 +25,13 @@ public class VendorSpec: QuickSpec { } it("fails to open app with invalid ID") { expect { - try Mas.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try Mas.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -44,7 +44,7 @@ public class VendorSpec: QuickSpec { ) storeSearch.apps[mockResult.trackId] = mockResult expect { - try Mas.Vendor.parse([String(mockResult.trackId)]) + try MAS.Vendor.parse([String(mockResult.trackId)]) .run(storeSearch: storeSearch, openCommand: openCommand) return openCommand.arguments } diff --git a/Tests/masTests/Commands/VersionSpec.swift b/Tests/masTests/Commands/VersionSpec.swift index 0828749..ec66b55 100644 --- a/Tests/masTests/Commands/VersionSpec.swift +++ b/Tests/masTests/Commands/VersionSpec.swift @@ -15,13 +15,13 @@ import Quick public class VersionSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("version command") { it("displays the current version") { expect { try captureStream(stdout) { - try Mas.Version.parse([]).run() + try MAS.Version.parse([]).run() } } == "\(Package.version)\n" diff --git a/Tests/masTests/Controllers/MasAppLibrarySpec.swift b/Tests/masTests/Controllers/MasAppLibrarySpec.swift index 69c2cc9..f484eb5 100644 --- a/Tests/masTests/Controllers/MasAppLibrarySpec.swift +++ b/Tests/masTests/Controllers/MasAppLibrarySpec.swift @@ -16,7 +16,7 @@ public class MasAppLibrarySpec: QuickSpec { let library = MasAppLibrary(softwareMap: SoftwareMapMock(products: apps)) beforeSuite { - Mas.initialize() + MAS.initialize() } describe("mas app library") { it("contains all installed apps") { diff --git a/Tests/masTests/Controllers/MasStoreSearchSpec.swift b/Tests/masTests/Controllers/MasStoreSearchSpec.swift index b6ce5df..3d75ff9 100644 --- a/Tests/masTests/Controllers/MasStoreSearchSpec.swift +++ b/Tests/masTests/Controllers/MasStoreSearchSpec.swift @@ -14,7 +14,7 @@ import Quick public class MasStoreSearchSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("url string") { it("contains the app name") { diff --git a/Tests/masTests/Errors/MASErrorTestCase.swift b/Tests/masTests/Errors/MASErrorTestCase.swift index 15cecfc..027a196 100644 --- a/Tests/masTests/Errors/MASErrorTestCase.swift +++ b/Tests/masTests/Errors/MASErrorTestCase.swift @@ -32,7 +32,7 @@ class MASErrorTestCase: XCTestCase { override func setUp() { super.setUp() - Mas.initialize() + MAS.initialize() nserror = NSError(domain: errorDomain, code: 999) localizedDescription = "foo" } diff --git a/Tests/masTests/ExternalCommands/OpenSystemCommandSpec.swift b/Tests/masTests/ExternalCommands/OpenSystemCommandSpec.swift index a9a5f0e..9b8c1f5 100644 --- a/Tests/masTests/ExternalCommands/OpenSystemCommandSpec.swift +++ b/Tests/masTests/ExternalCommands/OpenSystemCommandSpec.swift @@ -14,7 +14,7 @@ import Quick public class OpenSystemCommandSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("open system command") { context("binary path") { diff --git a/Tests/masTests/Formatters/AppListFormatterSpec.swift b/Tests/masTests/Formatters/AppListFormatterSpec.swift index 47b3b18..e8c61d6 100644 --- a/Tests/masTests/Formatters/AppListFormatterSpec.swift +++ b/Tests/masTests/Formatters/AppListFormatterSpec.swift @@ -18,7 +18,7 @@ public class AppListFormatterSpec: QuickSpec { var products: [SoftwareProduct] = [] beforeSuite { - Mas.initialize() + MAS.initialize() } describe("app list formatter") { beforeEach { diff --git a/Tests/masTests/Formatters/SearchResultFormatterSpec.swift b/Tests/masTests/Formatters/SearchResultFormatterSpec.swift index 1689fa0..f35a44d 100644 --- a/Tests/masTests/Formatters/SearchResultFormatterSpec.swift +++ b/Tests/masTests/Formatters/SearchResultFormatterSpec.swift @@ -18,7 +18,7 @@ public class SearchResultFormatterSpec: QuickSpec { var results: [SearchResult] = [] beforeSuite { - Mas.initialize() + MAS.initialize() } describe("search results formatter") { beforeEach { diff --git a/Tests/masTests/Models/SearchResultListSpec.swift b/Tests/masTests/Models/SearchResultListSpec.swift index 2804491..7895b1c 100644 --- a/Tests/masTests/Models/SearchResultListSpec.swift +++ b/Tests/masTests/Models/SearchResultListSpec.swift @@ -15,7 +15,7 @@ import Quick public class SearchResultListSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("search result list") { it("can parse bbedit") { diff --git a/Tests/masTests/Models/SearchResultSpec.swift b/Tests/masTests/Models/SearchResultSpec.swift index 460e961..9462456 100644 --- a/Tests/masTests/Models/SearchResultSpec.swift +++ b/Tests/masTests/Models/SearchResultSpec.swift @@ -15,7 +15,7 @@ import Quick public class SearchResultSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("search result") { it("can parse things") { diff --git a/Tests/masTests/Models/SoftwareProductSpec.swift b/Tests/masTests/Models/SoftwareProductSpec.swift index 80cbde3..ef0e6f1 100644 --- a/Tests/masTests/Models/SoftwareProductSpec.swift +++ b/Tests/masTests/Models/SoftwareProductSpec.swift @@ -15,7 +15,7 @@ import Quick public class SoftwareProductSpec: QuickSpec { override public func spec() { beforeSuite { - Mas.initialize() + MAS.initialize() } describe("software product") { let app = SoftwareProductMock( diff --git a/Tests/masTests/Network/NetworkManagerTests.swift b/Tests/masTests/Network/NetworkManagerTests.swift index 450bb39..751271c 100644 --- a/Tests/masTests/Network/NetworkManagerTests.swift +++ b/Tests/masTests/Network/NetworkManagerTests.swift @@ -13,7 +13,7 @@ import XCTest class NetworkManagerTests: XCTestCase { override func setUp() { super.setUp() - Mas.initialize() + MAS.initialize() } func testSuccessfulAsyncResponse() throws { From d7072fc66dda4e2b40bea8afc6a59e8d0cba603a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:29:17 -0400 Subject: [PATCH 7/9] Rename `*StoreSearch` as `*AppStoreSearcher`. Rename `MasStoreSearch` as `ITunesSearchAppStoreSearcher`. Rename `StoreSearchMock` as `MockAppStoreSearcher`. Rename variables/parameters of the above types as `searcher`. Fix 'App Store.app' mention in help. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Commands/Home.swift | 6 +++--- Sources/mas/Commands/Info.swift | 6 +++--- Sources/mas/Commands/Lucky.swift | 6 +++--- Sources/mas/Commands/Open.swift | 8 ++++---- Sources/mas/Commands/Outdated.swift | 6 +++--- Sources/mas/Commands/Search.swift | 6 +++--- Sources/mas/Commands/Upgrade.swift | 10 +++++----- Sources/mas/Commands/Vendor.swift | 6 +++--- ...{StoreSearch.swift => AppStoreSearcher.swift} | 6 +++--- ....swift => ITunesSearchAppStoreSearcher.swift} | 4 ++-- Tests/masTests/Commands/HomeSpec.swift | 12 ++++++------ Tests/masTests/Commands/InfoSpec.swift | 12 ++++++------ Tests/masTests/Commands/LuckySpec.swift | 4 ++-- Tests/masTests/Commands/OpenSpec.swift | 14 +++++++------- Tests/masTests/Commands/OutdatedSpec.swift | 6 +++--- Tests/masTests/Commands/SearchSpec.swift | 10 +++++----- Tests/masTests/Commands/UpgradeSpec.swift | 2 +- Tests/masTests/Commands/VendorSpec.swift | 12 ++++++------ ...ft => ITunesSearchAppStoreSearcherSpec.swift} | 16 ++++++++-------- ...archMock.swift => MockAppStoreSearcher.swift} | 4 ++-- contrib/completion/mas.fish | 2 +- 21 files changed, 79 insertions(+), 79 deletions(-) rename Sources/mas/Controllers/{StoreSearch.swift => AppStoreSearcher.swift} (96%) rename Sources/mas/Controllers/{MasStoreSearch.swift => ITunesSearchAppStoreSearcher.swift} (98%) rename Tests/masTests/Controllers/{MasStoreSearchSpec.swift => ITunesSearchAppStoreSearcherSpec.swift} (77%) rename Tests/masTests/Controllers/{StoreSearchMock.swift => MockAppStoreSearcher.swift} (88%) diff --git a/Sources/mas/Commands/Home.swift b/Sources/mas/Commands/Home.swift index d9d3b23..c9e186e 100644 --- a/Sources/mas/Commands/Home.swift +++ b/Sources/mas/Commands/Home.swift @@ -21,12 +21,12 @@ extension MAS { /// Runs the command. func run() throws { - try run(storeSearch: MasStoreSearch(), openCommand: OpenSystemCommand()) + try run(searcher: ITunesSearchAppStoreSearcher(), openCommand: OpenSystemCommand()) } - func run(storeSearch: StoreSearch, openCommand: ExternalCommand) throws { + func run(searcher: AppStoreSearcher, openCommand: ExternalCommand) throws { do { - guard let result = try storeSearch.lookup(appID: appID).wait() else { + guard let result = try searcher.lookup(appID: appID).wait() else { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Commands/Info.swift b/Sources/mas/Commands/Info.swift index e832d20..5352097 100644 --- a/Sources/mas/Commands/Info.swift +++ b/Sources/mas/Commands/Info.swift @@ -22,12 +22,12 @@ extension MAS { /// Runs the command. func run() throws { - try run(storeSearch: MasStoreSearch()) + try run(searcher: ITunesSearchAppStoreSearcher()) } - func run(storeSearch: StoreSearch) throws { + func run(searcher: AppStoreSearcher) throws { do { - guard let result = try storeSearch.lookup(appID: appID).wait() else { + guard let result = try searcher.lookup(appID: appID).wait() else { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Commands/Lucky.swift b/Sources/mas/Commands/Lucky.swift index f2a33c3..eba32b1 100644 --- a/Sources/mas/Commands/Lucky.swift +++ b/Sources/mas/Commands/Lucky.swift @@ -25,14 +25,14 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), storeSearch: MasStoreSearch()) + try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } - func run(appLibrary: AppLibrary, storeSearch: StoreSearch) throws { + func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { var appID: AppID? do { - let results = try storeSearch.search(for: searchTerm).wait() + let results = try searcher.search(for: searchTerm).wait() guard let result = results.first else { printError("No results found") throw MASError.noSearchResultsFound diff --git a/Sources/mas/Commands/Open.swift b/Sources/mas/Commands/Open.swift index c2369e9..a924895 100644 --- a/Sources/mas/Commands/Open.swift +++ b/Sources/mas/Commands/Open.swift @@ -16,7 +16,7 @@ extension MAS { /// https://performance-partners.apple.com/search-api struct Open: ParsableCommand { static let configuration = CommandConfiguration( - abstract: "Opens app page in AppStore.app" + abstract: "Opens app page in 'App Store.app'" ) @Argument(help: "the app ID") @@ -24,10 +24,10 @@ extension MAS { /// Runs the command. func run() throws { - try run(storeSearch: MasStoreSearch(), openCommand: OpenSystemCommand()) + try run(searcher: ITunesSearchAppStoreSearcher(), openCommand: OpenSystemCommand()) } - func run(storeSearch: StoreSearch, openCommand: ExternalCommand) throws { + func run(searcher: AppStoreSearcher, openCommand: ExternalCommand) throws { do { guard let appID else { // If no app ID is given, just open the MAS GUI app @@ -35,7 +35,7 @@ extension MAS { return } - guard let result = try storeSearch.lookup(appID: appID).wait() else { + guard let result = try searcher.lookup(appID: appID).wait() else { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Commands/Outdated.swift b/Sources/mas/Commands/Outdated.swift index 77325ba..94f5039 100644 --- a/Sources/mas/Commands/Outdated.swift +++ b/Sources/mas/Commands/Outdated.swift @@ -23,15 +23,15 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), storeSearch: MasStoreSearch()) + try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } - func run(appLibrary: AppLibrary, storeSearch: StoreSearch) throws { + func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { _ = try when( fulfilled: appLibrary.installedApps.map { installedApp in firstly { - storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue) + searcher.lookup(appID: installedApp.itemIdentifier.appIDValue) } .done { storeApp in guard let storeApp else { diff --git a/Sources/mas/Commands/Search.swift b/Sources/mas/Commands/Search.swift index ef14e1e..ae36163 100644 --- a/Sources/mas/Commands/Search.swift +++ b/Sources/mas/Commands/Search.swift @@ -23,12 +23,12 @@ extension MAS { var searchTerm: String func run() throws { - try run(storeSearch: MasStoreSearch()) + try run(searcher: ITunesSearchAppStoreSearcher()) } - func run(storeSearch: StoreSearch) throws { + func run(searcher: AppStoreSearcher) throws { do { - let results = try storeSearch.search(for: searchTerm).wait() + let results = try searcher.search(for: searchTerm).wait() if results.isEmpty { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index 079550e..a0db6f8 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -22,13 +22,13 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), storeSearch: MasStoreSearch()) + try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } - func run(appLibrary: AppLibrary, storeSearch: StoreSearch) throws { + func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { let apps: [(installedApp: SoftwareProduct, storeApp: SearchResult)] do { - apps = try findOutdatedApps(appLibrary: appLibrary, storeSearch: storeSearch) + apps = try findOutdatedApps(appLibrary: appLibrary, searcher: searcher) } catch { throw error as? MASError ?? .searchFailed } @@ -53,7 +53,7 @@ extension MAS { private func findOutdatedApps( appLibrary: AppLibrary, - storeSearch: StoreSearch + searcher: AppStoreSearcher ) throws -> [(SoftwareProduct, SearchResult)] { let apps = appIDs.isEmpty @@ -71,7 +71,7 @@ extension MAS { let promises = apps.map { installedApp in // only upgrade apps whose local version differs from the store version firstly { - storeSearch.lookup(appID: installedApp.itemIdentifier.appIDValue) + searcher.lookup(appID: installedApp.itemIdentifier.appIDValue) } .map { result -> (SoftwareProduct, SearchResult)? in guard let storeApp = result, installedApp.isOutdatedWhenComparedTo(storeApp) else { diff --git a/Sources/mas/Commands/Vendor.swift b/Sources/mas/Commands/Vendor.swift index d3004a1..31189e3 100644 --- a/Sources/mas/Commands/Vendor.swift +++ b/Sources/mas/Commands/Vendor.swift @@ -21,12 +21,12 @@ extension MAS { /// Runs the command. func run() throws { - try run(storeSearch: MasStoreSearch(), openCommand: OpenSystemCommand()) + try run(searcher: ITunesSearchAppStoreSearcher(), openCommand: OpenSystemCommand()) } - func run(storeSearch: StoreSearch, openCommand: ExternalCommand) throws { + func run(searcher: AppStoreSearcher, openCommand: ExternalCommand) throws { do { - guard let result = try storeSearch.lookup(appID: appID).wait() else { + guard let result = try searcher.lookup(appID: appID).wait() else { throw MASError.noSearchResultsFound } diff --git a/Sources/mas/Controllers/StoreSearch.swift b/Sources/mas/Controllers/AppStoreSearcher.swift similarity index 96% rename from Sources/mas/Controllers/StoreSearch.swift rename to Sources/mas/Controllers/AppStoreSearcher.swift index 0b8194c..4e5b65e 100644 --- a/Sources/mas/Controllers/StoreSearch.swift +++ b/Sources/mas/Controllers/AppStoreSearcher.swift @@ -1,5 +1,5 @@ // -// StoreSearch.swift +// AppStoreSearcher.swift // mas // // Created by Ben Chatelain on 12/29/18. @@ -10,7 +10,7 @@ import Foundation import PromiseKit /// Protocol for searching the MAS catalog. -protocol StoreSearch { +protocol AppStoreSearcher { func lookup(appID: AppID) -> Promise func search(for searchTerm: String) -> Promise<[SearchResult]> } @@ -37,7 +37,7 @@ private enum URLAction { } // MARK: - Common methods -extension StoreSearch { +extension AppStoreSearcher { /// Builds the search URL for an app. /// /// - Parameters: diff --git a/Sources/mas/Controllers/MasStoreSearch.swift b/Sources/mas/Controllers/ITunesSearchAppStoreSearcher.swift similarity index 98% rename from Sources/mas/Controllers/MasStoreSearch.swift rename to Sources/mas/Controllers/ITunesSearchAppStoreSearcher.swift index a046778..c6de321 100644 --- a/Sources/mas/Controllers/MasStoreSearch.swift +++ b/Sources/mas/Controllers/ITunesSearchAppStoreSearcher.swift @@ -1,5 +1,5 @@ // -// MasStoreSearch.swift +// ITunesSearchAppStoreSearcher.swift // mas // // Created by Ben Chatelain on 12/29/18. @@ -12,7 +12,7 @@ import Regex import Version /// Manages searching the MAS catalog through the iTunes Search and Lookup APIs. -class MasStoreSearch: StoreSearch { +class ITunesSearchAppStoreSearcher: AppStoreSearcher { private static let appVersionExpression = Regex(#"\"versionDisplay\"\:\"([^\"]+)\""#) // CommerceKit and StoreFoundation don't seem to expose the region of the Apple ID signed diff --git a/Tests/masTests/Commands/HomeSpec.swift b/Tests/masTests/Commands/HomeSpec.swift index 46d22f6..8e04cf9 100644 --- a/Tests/masTests/Commands/HomeSpec.swift +++ b/Tests/masTests/Commands/HomeSpec.swift @@ -13,7 +13,7 @@ import Quick public class HomeSpec: QuickSpec { override public func spec() { - let storeSearch = StoreSearchMock() + let searcher = MockAppStoreSearcher() let openCommand = OpenSystemCommandMock() beforeSuite { @@ -21,17 +21,17 @@ public class HomeSpec: QuickSpec { } describe("home command") { beforeEach { - storeSearch.reset() + searcher.reset() } it("fails to open app with invalid ID") { expect { - try MAS.Home.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Home.parse(["--", "-999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try MAS.Home.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Home.parse(["999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -41,10 +41,10 @@ public class HomeSpec: QuickSpec { trackViewUrl: "mas preview url", version: "0.0" ) - storeSearch.apps[mockResult.trackId] = mockResult + searcher.apps[mockResult.trackId] = mockResult expect { try MAS.Home.parse([String(mockResult.trackId)]) - .run(storeSearch: storeSearch, openCommand: openCommand) + .run(searcher: searcher, openCommand: openCommand) return openCommand.arguments } == [mockResult.trackViewUrl] diff --git a/Tests/masTests/Commands/InfoSpec.swift b/Tests/masTests/Commands/InfoSpec.swift index 400ddb6..3632480 100644 --- a/Tests/masTests/Commands/InfoSpec.swift +++ b/Tests/masTests/Commands/InfoSpec.swift @@ -14,24 +14,24 @@ import Quick public class InfoSpec: QuickSpec { override public func spec() { - let storeSearch = StoreSearchMock() + let searcher = MockAppStoreSearcher() beforeSuite { MAS.initialize() } describe("Info command") { beforeEach { - storeSearch.reset() + searcher.reset() } it("fails to open app with invalid ID") { expect { - try MAS.Info.parse(["--", "-999"]).run(storeSearch: storeSearch) + try MAS.Info.parse(["--", "-999"]).run(searcher: searcher) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try MAS.Info.parse(["999"]).run(storeSearch: storeSearch) + try MAS.Info.parse(["999"]).run(searcher: searcher) } .to(throwError(MASError.noSearchResultsFound)) } @@ -47,10 +47,10 @@ public class InfoSpec: QuickSpec { trackViewUrl: "https://awesome.app", version: "1.0" ) - storeSearch.apps[mockResult.trackId] = mockResult + searcher.apps[mockResult.trackId] = mockResult expect { try captureStream(stdout) { - try MAS.Info.parse([String(mockResult.trackId)]).run(storeSearch: storeSearch) + try MAS.Info.parse([String(mockResult.trackId)]).run(searcher: searcher) } } == """ diff --git a/Tests/masTests/Commands/LuckySpec.swift b/Tests/masTests/Commands/LuckySpec.swift index fa73ab9..26eff44 100644 --- a/Tests/masTests/Commands/LuckySpec.swift +++ b/Tests/masTests/Commands/LuckySpec.swift @@ -14,7 +14,7 @@ import Quick public class LuckySpec: QuickSpec { override public func spec() { let networkSession = NetworkSessionMockFromFile(responseFile: "search/slack.json") - let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession)) + let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) beforeSuite { MAS.initialize() @@ -22,7 +22,7 @@ public class LuckySpec: QuickSpec { xdescribe("lucky command") { xit("installs the first app matching a search") { expect { - try MAS.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), storeSearch: storeSearch) + try MAS.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), searcher: searcher) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/OpenSpec.swift b/Tests/masTests/Commands/OpenSpec.swift index 23b7119..8459f7b 100644 --- a/Tests/masTests/Commands/OpenSpec.swift +++ b/Tests/masTests/Commands/OpenSpec.swift @@ -14,7 +14,7 @@ import Quick public class OpenSpec: QuickSpec { override public func spec() { - let storeSearch = StoreSearchMock() + let searcher = MockAppStoreSearcher() let openCommand = OpenSystemCommandMock() beforeSuite { @@ -22,17 +22,17 @@ public class OpenSpec: QuickSpec { } describe("open command") { beforeEach { - storeSearch.reset() + searcher.reset() } it("fails to open app with invalid ID") { expect { - try MAS.Open.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse(["--", "-999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try MAS.Open.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse(["999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -42,17 +42,17 @@ public class OpenSpec: QuickSpec { trackViewUrl: "fakescheme://some/url", version: "0.0" ) - storeSearch.apps[mockResult.trackId] = mockResult + searcher.apps[mockResult.trackId] = mockResult expect { try MAS.Open.parse([mockResult.trackId.description]) - .run(storeSearch: storeSearch, openCommand: openCommand) + .run(searcher: searcher, openCommand: openCommand) return openCommand.arguments } == ["macappstore://some/url"] } it("just opens MAS if no app specified") { expect { - try MAS.Open.parse([]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Open.parse([]).run(searcher: searcher, openCommand: openCommand) return openCommand.arguments } == ["macappstore://"] diff --git a/Tests/masTests/Commands/OutdatedSpec.swift b/Tests/masTests/Commands/OutdatedSpec.swift index 72e0f50..6ca3d01 100644 --- a/Tests/masTests/Commands/OutdatedSpec.swift +++ b/Tests/masTests/Commands/OutdatedSpec.swift @@ -33,8 +33,8 @@ public class OutdatedSpec: QuickSpec { trackViewUrl: "https://apps.apple.com/us/app/bandwidth/id490461369?mt=12&uo=4", version: "1.28" ) - let mockStoreSearch = StoreSearchMock() - mockStoreSearch.apps[mockSearchResult.trackId] = mockSearchResult + let searcher = MockAppStoreSearcher() + searcher.apps[mockSearchResult.trackId] = mockSearchResult let mockAppLibrary = AppLibraryMock() mockAppLibrary.installedApps.append( @@ -48,7 +48,7 @@ public class OutdatedSpec: QuickSpec { ) expect { try captureStream(stdout) { - try MAS.Outdated.parse([]).run(appLibrary: mockAppLibrary, storeSearch: mockStoreSearch) + try MAS.Outdated.parse([]).run(appLibrary: mockAppLibrary, searcher: searcher) } } == "490461369 Bandwidth+ (1.27 -> 1.28)\n" diff --git a/Tests/masTests/Commands/SearchSpec.swift b/Tests/masTests/Commands/SearchSpec.swift index 3984fa1..058f5c4 100644 --- a/Tests/masTests/Commands/SearchSpec.swift +++ b/Tests/masTests/Commands/SearchSpec.swift @@ -14,14 +14,14 @@ import Quick public class SearchSpec: QuickSpec { override public func spec() { - let storeSearch = StoreSearchMock() + let searcher = MockAppStoreSearcher() beforeSuite { MAS.initialize() } describe("search command") { beforeEach { - storeSearch.reset() + searcher.reset() } it("can find slack") { let mockResult = SearchResult( @@ -30,17 +30,17 @@ public class SearchSpec: QuickSpec { trackViewUrl: "mas preview url", version: "0.0" ) - storeSearch.apps[mockResult.trackId] = mockResult + searcher.apps[mockResult.trackId] = mockResult expect { try captureStream(stdout) { - try MAS.Search.parse(["slack"]).run(storeSearch: storeSearch) + try MAS.Search.parse(["slack"]).run(searcher: searcher) } } == " 1111 slack (0.0)\n" } it("fails when searching for nonexistent app") { expect { - try MAS.Search.parse(["nonexistent"]).run(storeSearch: storeSearch) + try MAS.Search.parse(["nonexistent"]).run(searcher: searcher) } .to(throwError(MASError.noSearchResultsFound)) } diff --git a/Tests/masTests/Commands/UpgradeSpec.swift b/Tests/masTests/Commands/UpgradeSpec.swift index 585e751..e2d42f6 100644 --- a/Tests/masTests/Commands/UpgradeSpec.swift +++ b/Tests/masTests/Commands/UpgradeSpec.swift @@ -22,7 +22,7 @@ public class UpgradeSpec: QuickSpec { expect { try captureStream(stderr) { try MAS.Upgrade.parse([]) - .run(appLibrary: AppLibraryMock(), storeSearch: StoreSearchMock()) + .run(appLibrary: AppLibraryMock(), searcher: MockAppStoreSearcher()) } } == "Warning: Nothing found to upgrade\n" diff --git a/Tests/masTests/Commands/VendorSpec.swift b/Tests/masTests/Commands/VendorSpec.swift index a73d1e1..8291658 100644 --- a/Tests/masTests/Commands/VendorSpec.swift +++ b/Tests/masTests/Commands/VendorSpec.swift @@ -13,7 +13,7 @@ import Quick public class VendorSpec: QuickSpec { override public func spec() { - let storeSearch = StoreSearchMock() + let searcher = MockAppStoreSearcher() let openCommand = OpenSystemCommandMock() beforeSuite { @@ -21,17 +21,17 @@ public class VendorSpec: QuickSpec { } describe("vendor command") { beforeEach { - storeSearch.reset() + searcher.reset() } it("fails to open app with invalid ID") { expect { - try MAS.Vendor.parse(["--", "-999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Vendor.parse(["--", "-999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError()) } it("can't find app with unknown ID") { expect { - try MAS.Vendor.parse(["999"]).run(storeSearch: storeSearch, openCommand: openCommand) + try MAS.Vendor.parse(["999"]).run(searcher: searcher, openCommand: openCommand) } .to(throwError(MASError.noSearchResultsFound)) } @@ -42,10 +42,10 @@ public class VendorSpec: QuickSpec { trackViewUrl: "https://apps.apple.com/us/app/awesome/id1111?mt=12&uo=4", version: "0.0" ) - storeSearch.apps[mockResult.trackId] = mockResult + searcher.apps[mockResult.trackId] = mockResult expect { try MAS.Vendor.parse([String(mockResult.trackId)]) - .run(storeSearch: storeSearch, openCommand: openCommand) + .run(searcher: searcher, openCommand: openCommand) return openCommand.arguments } == [mockResult.sellerUrl] diff --git a/Tests/masTests/Controllers/MasStoreSearchSpec.swift b/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift similarity index 77% rename from Tests/masTests/Controllers/MasStoreSearchSpec.swift rename to Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift index 3d75ff9..3e9f9cd 100644 --- a/Tests/masTests/Controllers/MasStoreSearchSpec.swift +++ b/Tests/masTests/Controllers/ITunesSearchAppStoreSearcherSpec.swift @@ -1,5 +1,5 @@ // -// MasStoreSearchSpec.swift +// ITunesSearchAppStoreSearcherSpec.swift // masTests // // Created by Ben Chatelain on 1/4/19. @@ -11,7 +11,7 @@ import Quick @testable import mas -public class MasStoreSearchSpec: QuickSpec { +public class ITunesSearchAppStoreSearcherSpec: QuickSpec { override public func spec() { beforeSuite { MAS.initialize() @@ -19,13 +19,13 @@ public class MasStoreSearchSpec: QuickSpec { describe("url string") { it("contains the app name") { expect { - MasStoreSearch().searchURL(for: "myapp", inCountry: "US")?.absoluteString + ITunesSearchAppStoreSearcher().searchURL(for: "myapp", inCountry: "US")?.absoluteString } == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&country=US&term=myapp" } it("contains the encoded app name") { expect { - MasStoreSearch().searchURL(for: "My App", inCountry: "US")?.absoluteString + ITunesSearchAppStoreSearcher().searchURL(for: "My App", inCountry: "US")?.absoluteString } == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&country=US&term=My%20App" } @@ -34,10 +34,10 @@ public class MasStoreSearchSpec: QuickSpec { context("when searched") { it("can find slack") { let networkSession = NetworkSessionMockFromFile(responseFile: "search/slack.json") - let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession)) + let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) expect { - try storeSearch.search(for: "slack").wait() + try searcher.search(for: "slack").wait() } .to(haveCount(39)) } @@ -47,11 +47,11 @@ public class MasStoreSearchSpec: QuickSpec { it("can find slack") { let appID: AppID = 803_453_959 let networkSession = NetworkSessionMockFromFile(responseFile: "lookup/slack.json") - let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession)) + let searcher = ITunesSearchAppStoreSearcher(networkManager: NetworkManager(session: networkSession)) var result: SearchResult? do { - result = try storeSearch.lookup(appID: appID).wait() + result = try searcher.lookup(appID: appID).wait() } catch { let maserror = error as! MASError if case .jsonParsing(let nserror) = maserror { diff --git a/Tests/masTests/Controllers/StoreSearchMock.swift b/Tests/masTests/Controllers/MockAppStoreSearcher.swift similarity index 88% rename from Tests/masTests/Controllers/StoreSearchMock.swift rename to Tests/masTests/Controllers/MockAppStoreSearcher.swift index 4b5143d..1df0ef6 100644 --- a/Tests/masTests/Controllers/StoreSearchMock.swift +++ b/Tests/masTests/Controllers/MockAppStoreSearcher.swift @@ -1,5 +1,5 @@ // -// StoreSearchMock.swift +// MockAppStoreSearcher.swift // masTests // // Created by Ben Chatelain on 1/4/19. @@ -10,7 +10,7 @@ import PromiseKit @testable import mas -class StoreSearchMock: StoreSearch { +class MockAppStoreSearcher: AppStoreSearcher { var apps: [AppID: SearchResult] = [:] func search(for searchTerm: String) -> Promise<[SearchResult]> { diff --git a/contrib/completion/mas.fish b/contrib/completion/mas.fish index 592218a..de9576f 100644 --- a/contrib/completion/mas.fish +++ b/contrib/completion/mas.fish @@ -46,7 +46,7 @@ complete -c mas -n "__fish_seen_subcommand_from help" -xa "list" complete -c mas -n "__fish_use_subcommand" -f -a lucky -d "Install the first result from the Mac App Store" complete -c mas -n "__fish_seen_subcommand_from help" -xa "lucky" ### open -complete -c mas -n "__fish_use_subcommand" -f -a open -d "Opens app page in AppStore.app" +complete -c mas -n "__fish_use_subcommand" -f -a open -d "Opens app page in 'App Store.app'" complete -c mas -n "__fish_seen_subcommand_from help" -xa "open" ### outdated complete -c mas -n "__fish_use_subcommand" -f -a outdated -d "Lists pending updates from the Mac App Store" From cc219fe644a9ff667e664c32811b4b13439675fd Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:48:03 -0400 Subject: [PATCH 8/9] Rename `MasAppLibrary` as `SoftwareMapAppLibrary`. Rename `AppLibraryMock` as `MockAppLibrary`. Partial #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/Commands/Install.swift | 2 +- Sources/mas/Commands/List.swift | 2 +- Sources/mas/Commands/Lucky.swift | 2 +- Sources/mas/Commands/Outdated.swift | 2 +- Sources/mas/Commands/Purchase.swift | 2 +- Sources/mas/Commands/Uninstall.swift | 2 +- Sources/mas/Commands/Upgrade.swift | 2 +- .../{MasAppLibrary.swift => SoftwareMapAppLibrary.swift} | 4 ++-- Tests/masTests/Commands/InstallSpec.swift | 2 +- Tests/masTests/Commands/ListSpec.swift | 2 +- Tests/masTests/Commands/LuckySpec.swift | 2 +- Tests/masTests/Commands/OutdatedSpec.swift | 2 +- Tests/masTests/Commands/PurchaseSpec.swift | 2 +- Tests/masTests/Commands/UninstallSpec.swift | 2 +- Tests/masTests/Commands/UpgradeSpec.swift | 2 +- .../{AppLibraryMock.swift => MockAppLibrary.swift} | 6 +++--- ...AppLibrarySpec.swift => SoftwareMapAppLibrarySpec.swift} | 6 +++--- 17 files changed, 22 insertions(+), 22 deletions(-) rename Sources/mas/Controllers/{MasAppLibrary.swift => SoftwareMapAppLibrary.swift} (98%) rename Tests/masTests/Controllers/{AppLibraryMock.swift => MockAppLibrary.swift} (87%) rename Tests/masTests/Controllers/{MasAppLibrarySpec.swift => SoftwareMapAppLibrarySpec.swift} (88%) diff --git a/Sources/mas/Commands/Install.swift b/Sources/mas/Commands/Install.swift index 2b13081..9b051e7 100644 --- a/Sources/mas/Commands/Install.swift +++ b/Sources/mas/Commands/Install.swift @@ -23,7 +23,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary()) + try run(appLibrary: SoftwareMapAppLibrary()) } func run(appLibrary: AppLibrary) throws { diff --git a/Sources/mas/Commands/List.swift b/Sources/mas/Commands/List.swift index eb782e2..94544c9 100644 --- a/Sources/mas/Commands/List.swift +++ b/Sources/mas/Commands/List.swift @@ -17,7 +17,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary()) + try run(appLibrary: SoftwareMapAppLibrary()) } func run(appLibrary: AppLibrary) throws { diff --git a/Sources/mas/Commands/Lucky.swift b/Sources/mas/Commands/Lucky.swift index eba32b1..781f55f 100644 --- a/Sources/mas/Commands/Lucky.swift +++ b/Sources/mas/Commands/Lucky.swift @@ -25,7 +25,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) + try run(appLibrary: SoftwareMapAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { diff --git a/Sources/mas/Commands/Outdated.swift b/Sources/mas/Commands/Outdated.swift index 94f5039..a495c1b 100644 --- a/Sources/mas/Commands/Outdated.swift +++ b/Sources/mas/Commands/Outdated.swift @@ -23,7 +23,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) + try run(appLibrary: SoftwareMapAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { diff --git a/Sources/mas/Commands/Purchase.swift b/Sources/mas/Commands/Purchase.swift index 66f4c92..d775c64 100644 --- a/Sources/mas/Commands/Purchase.swift +++ b/Sources/mas/Commands/Purchase.swift @@ -20,7 +20,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary()) + try run(appLibrary: SoftwareMapAppLibrary()) } func run(appLibrary: AppLibrary) throws { diff --git a/Sources/mas/Commands/Uninstall.swift b/Sources/mas/Commands/Uninstall.swift index 68561c7..d9997a7 100644 --- a/Sources/mas/Commands/Uninstall.swift +++ b/Sources/mas/Commands/Uninstall.swift @@ -24,7 +24,7 @@ extension MAS { /// Runs the uninstall command. func run() throws { - try run(appLibrary: MasAppLibrary()) + try run(appLibrary: SoftwareMapAppLibrary()) } func run(appLibrary: AppLibrary) throws { diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index a0db6f8..1c1630d 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -22,7 +22,7 @@ extension MAS { /// Runs the command. func run() throws { - try run(appLibrary: MasAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) + try run(appLibrary: SoftwareMapAppLibrary(), searcher: ITunesSearchAppStoreSearcher()) } func run(appLibrary: AppLibrary, searcher: AppStoreSearcher) throws { diff --git a/Sources/mas/Controllers/MasAppLibrary.swift b/Sources/mas/Controllers/SoftwareMapAppLibrary.swift similarity index 98% rename from Sources/mas/Controllers/MasAppLibrary.swift rename to Sources/mas/Controllers/SoftwareMapAppLibrary.swift index d9e2f7d..7fc48e7 100644 --- a/Sources/mas/Controllers/MasAppLibrary.swift +++ b/Sources/mas/Controllers/SoftwareMapAppLibrary.swift @@ -1,5 +1,5 @@ // -// MasAppLibrary.swift +// SoftwareMapAppLibrary.swift // mas // // Created by Ben Chatelain on 12/27/18. @@ -10,7 +10,7 @@ import CommerceKit import ScriptingBridge /// Utility for managing installed apps. -class MasAppLibrary: AppLibrary { +class SoftwareMapAppLibrary: AppLibrary { /// CommerceKit's singleton manager of installed software. private let softwareMap: SoftwareMap diff --git a/Tests/masTests/Commands/InstallSpec.swift b/Tests/masTests/Commands/InstallSpec.swift index 88ad308..e2074c6 100644 --- a/Tests/masTests/Commands/InstallSpec.swift +++ b/Tests/masTests/Commands/InstallSpec.swift @@ -19,7 +19,7 @@ public class InstallSpec: QuickSpec { xdescribe("install command") { xit("installs apps") { expect { - try MAS.Install.parse([]).run(appLibrary: AppLibraryMock()) + try MAS.Install.parse([]).run(appLibrary: MockAppLibrary()) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/ListSpec.swift b/Tests/masTests/Commands/ListSpec.swift index c72bdf6..e9c02d6 100644 --- a/Tests/masTests/Commands/ListSpec.swift +++ b/Tests/masTests/Commands/ListSpec.swift @@ -21,7 +21,7 @@ public class ListSpec: QuickSpec { it("lists apps") { expect { try captureStream(stderr) { - try MAS.List.parse([]).run(appLibrary: AppLibraryMock()) + try MAS.List.parse([]).run(appLibrary: MockAppLibrary()) } } == "Error: No installed apps found\n" diff --git a/Tests/masTests/Commands/LuckySpec.swift b/Tests/masTests/Commands/LuckySpec.swift index 26eff44..cf35504 100644 --- a/Tests/masTests/Commands/LuckySpec.swift +++ b/Tests/masTests/Commands/LuckySpec.swift @@ -22,7 +22,7 @@ public class LuckySpec: QuickSpec { xdescribe("lucky command") { xit("installs the first app matching a search") { expect { - try MAS.Lucky.parse(["Slack"]).run(appLibrary: AppLibraryMock(), searcher: searcher) + try MAS.Lucky.parse(["Slack"]).run(appLibrary: MockAppLibrary(), searcher: searcher) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/OutdatedSpec.swift b/Tests/masTests/Commands/OutdatedSpec.swift index 6ca3d01..5831c56 100644 --- a/Tests/masTests/Commands/OutdatedSpec.swift +++ b/Tests/masTests/Commands/OutdatedSpec.swift @@ -36,7 +36,7 @@ public class OutdatedSpec: QuickSpec { let searcher = MockAppStoreSearcher() searcher.apps[mockSearchResult.trackId] = mockSearchResult - let mockAppLibrary = AppLibraryMock() + let mockAppLibrary = MockAppLibrary() mockAppLibrary.installedApps.append( SoftwareProductMock( appName: mockSearchResult.trackName, diff --git a/Tests/masTests/Commands/PurchaseSpec.swift b/Tests/masTests/Commands/PurchaseSpec.swift index 798a5e8..ac9db18 100644 --- a/Tests/masTests/Commands/PurchaseSpec.swift +++ b/Tests/masTests/Commands/PurchaseSpec.swift @@ -19,7 +19,7 @@ public class PurchaseSpec: QuickSpec { xdescribe("purchase command") { xit("purchases apps") { expect { - try MAS.Purchase.parse(["999"]).run(appLibrary: AppLibraryMock()) + try MAS.Purchase.parse(["999"]).run(appLibrary: MockAppLibrary()) } .toNot(throwError()) } diff --git a/Tests/masTests/Commands/UninstallSpec.swift b/Tests/masTests/Commands/UninstallSpec.swift index fbc3c1a..bfd68d0 100644 --- a/Tests/masTests/Commands/UninstallSpec.swift +++ b/Tests/masTests/Commands/UninstallSpec.swift @@ -26,7 +26,7 @@ public class UninstallSpec: QuickSpec { bundleVersion: "1.0", itemIdentifier: NSNumber(value: appID) ) - let mockLibrary = AppLibraryMock() + let mockLibrary = MockAppLibrary() context("dry run") { let uninstall = try! MAS.Uninstall.parse(["--dry-run", String(appID)]) diff --git a/Tests/masTests/Commands/UpgradeSpec.swift b/Tests/masTests/Commands/UpgradeSpec.swift index e2d42f6..6630777 100644 --- a/Tests/masTests/Commands/UpgradeSpec.swift +++ b/Tests/masTests/Commands/UpgradeSpec.swift @@ -22,7 +22,7 @@ public class UpgradeSpec: QuickSpec { expect { try captureStream(stderr) { try MAS.Upgrade.parse([]) - .run(appLibrary: AppLibraryMock(), searcher: MockAppStoreSearcher()) + .run(appLibrary: MockAppLibrary(), searcher: MockAppStoreSearcher()) } } == "Warning: Nothing found to upgrade\n" diff --git a/Tests/masTests/Controllers/AppLibraryMock.swift b/Tests/masTests/Controllers/MockAppLibrary.swift similarity index 87% rename from Tests/masTests/Controllers/AppLibraryMock.swift rename to Tests/masTests/Controllers/MockAppLibrary.swift index 96ac534..c992abc 100644 --- a/Tests/masTests/Controllers/AppLibraryMock.swift +++ b/Tests/masTests/Controllers/MockAppLibrary.swift @@ -1,5 +1,5 @@ // -// AppLibraryMock.swift +// MockAppLibrary.swift // masTests // // Created by Ben Chatelain on 12/27/18. @@ -8,7 +8,7 @@ @testable import mas -class AppLibraryMock: AppLibrary { +class MockAppLibrary: AppLibrary { var installedApps: [SoftwareProduct] = [] func uninstallApps(atPaths appPaths: [String]) throws { @@ -20,7 +20,7 @@ class AppLibraryMock: AppLibrary { } /// Members not part of the AppLibrary protocol that are only for test state management. -extension AppLibraryMock { +extension MockAppLibrary { /// Clears out the list of installed apps. func reset() { installedApps = [] diff --git a/Tests/masTests/Controllers/MasAppLibrarySpec.swift b/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift similarity index 88% rename from Tests/masTests/Controllers/MasAppLibrarySpec.swift rename to Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift index f484eb5..47b29f4 100644 --- a/Tests/masTests/Controllers/MasAppLibrarySpec.swift +++ b/Tests/masTests/Controllers/SoftwareMapAppLibrarySpec.swift @@ -1,5 +1,5 @@ // -// MasAppLibrarySpec.swift +// SoftwareMapAppLibrarySpec.swift // masTests // // Created by Ben Chatelain on 3/1/20. @@ -11,9 +11,9 @@ import Quick @testable import mas -public class MasAppLibrarySpec: QuickSpec { +public class SoftwareMapAppLibrarySpec: QuickSpec { override public func spec() { - let library = MasAppLibrary(softwareMap: SoftwareMapMock(products: apps)) + let library = SoftwareMapAppLibrary(softwareMap: SoftwareMapMock(products: apps)) beforeSuite { MAS.initialize() 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 9/9] 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