mirror of
https://github.com/mas-cli/mas
synced 2024-11-28 06:20:35 +00:00
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>
This commit is contained in:
parent
ab22e22ace
commit
d7072fc66d
21 changed files with 79 additions and 79 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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<SearchResult?>
|
||||
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:
|
|
@ -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
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
== """
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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://"]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 {
|
|
@ -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]> {
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue