Add appID parameter to MASError.notInstalled().

Partial #313

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-23 12:57:34 -04:00
parent 222646159d
commit b0d2f23465
No known key found for this signature in database
5 changed files with 9 additions and 9 deletions

View file

@ -30,7 +30,7 @@ extension Mas {
func run(appLibrary: AppLibrary) throws {
let installedApps = appLibrary.installedApps(withAppID: appID)
guard !installedApps.isEmpty else {
throw MASError.notInstalled
throw MASError.notInstalled(appID: appID)
}
if dryRun {

View file

@ -27,7 +27,7 @@ enum MASError: Error, Equatable {
case noSearchResultsFound
case noVendorWebsite
case notInstalled
case notInstalled(appID: AppID)
case uninstallFailed
case noData
@ -80,8 +80,8 @@ extension MASError: CustomStringConvertible {
return "No results found"
case .noVendorWebsite:
return "App does not have a vendor website"
case .notInstalled:
return "Not installed"
case .notInstalled(let appID):
return "No apps installed with app ID \(appID)"
case .uninstallFailed:
return "Uninstall failed"
case .noData:

View file

@ -38,7 +38,7 @@ public class UninstallSpec: QuickSpec {
expect {
try uninstall.run(appLibrary: mockLibrary)
}
.to(throwError(MASError.notInstalled))
.to(throwError(MASError.notInstalled(appID: appID)))
}
it("finds an app") {
mockLibrary.installedApps.append(app)
@ -58,7 +58,7 @@ public class UninstallSpec: QuickSpec {
expect {
try uninstall.run(appLibrary: mockLibrary)
}
.to(throwError(MASError.notInstalled))
.to(throwError(MASError.notInstalled(appID: appID)))
}
it("removes an app") {
mockLibrary.installedApps.append(app)

View file

@ -15,7 +15,7 @@ class AppLibraryMock: AppLibrary {
if !installedApps.contains(where: { product -> Bool in
app.itemIdentifier == product.itemIdentifier
}) {
throw MASError.notInstalled
throw MASError.notInstalled(appID: app.itemIdentifier.appIDValue)
}
// Special case for testing where we pretend the trash command failed

View file

@ -109,8 +109,8 @@ class MASErrorTestCase: XCTestCase {
}
func testNotInstalled() {
error = .notInstalled
XCTAssertEqual(error.description, "Not installed")
error = .notInstalled(appID: 123)
XCTAssertEqual(error.description, "No apps installed with app ID 123")
}
func testUninstallFailed() {