mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
Add appID
parameter to MASError.notInstalled()
.
Partial #313 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
222646159d
commit
b0d2f23465
5 changed files with 9 additions and 9 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue