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 { func run(appLibrary: AppLibrary) throws {
let installedApps = appLibrary.installedApps(withAppID: appID) let installedApps = appLibrary.installedApps(withAppID: appID)
guard !installedApps.isEmpty else { guard !installedApps.isEmpty else {
throw MASError.notInstalled throw MASError.notInstalled(appID: appID)
} }
if dryRun { if dryRun {

View file

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

View file

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

View file

@ -15,7 +15,7 @@ class AppLibraryMock: AppLibrary {
if !installedApps.contains(where: { product -> Bool in if !installedApps.contains(where: { product -> Bool in
app.itemIdentifier == product.itemIdentifier 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 // Special case for testing where we pretend the trash command failed

View file

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