mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 11:33:13 +00:00
commit
45f08747cf
63 changed files with 179 additions and 158 deletions
1
.swift-version
Normal file
1
.swift-version
Normal file
|
@ -0,0 +1 @@
|
|||
4.2
|
18
.swiftformat
Normal file
18
.swiftformat
Normal file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# .swiftformat
|
||||
# mas-cli
|
||||
#
|
||||
# https://github.com/nicklockwood/SwiftFormat#config-file
|
||||
#
|
||||
|
||||
--exclude Carthage/
|
||||
|
||||
# Disabled rules
|
||||
--disable blankLinesAroundMark
|
||||
|
||||
# Enabled rules (disabled by default)
|
||||
--enable trailingClosures
|
||||
|
||||
# Rule options
|
||||
--commas inline
|
||||
--importgrouping testable-top
|
1
Brewfile
1
Brewfile
|
@ -1,3 +1,4 @@
|
|||
brew "carthage"
|
||||
brew "shellcheck"
|
||||
brew "swiftlint"
|
||||
brew "swiftformat"
|
||||
|
|
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- 🎨 SwiftFormat #215
|
||||
- ⬆️ Nimble (7.3.2) #213
|
||||
- ⬆️ Quick (1.3.2) #213
|
||||
- ⬆️ Result (4.1.0) #213
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
// Copyright (c) 2015 Andrew Naylor. All rights reserved.
|
||||
//
|
||||
|
||||
import StoreFoundation
|
||||
import CommerceKit
|
||||
import StoreFoundation
|
||||
|
||||
extension ISStoreAccount: StoreAccount {
|
||||
static var primaryAccountIsPresentAndSignedIn: Bool {
|
||||
|
|
|
@ -31,7 +31,7 @@ import StoreFoundation
|
|||
}
|
||||
}
|
||||
|
||||
func downloadQueue(_ queue: CKDownloadQueue, changedWithAddition download: SSDownload) {
|
||||
func downloadQueue(_: CKDownloadQueue, changedWithAddition download: SSDownload) {
|
||||
guard download.metadata.itemIdentifier == purchase.itemIdentifier else {
|
||||
return
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import StoreFoundation
|
|||
printInfo("Downloading \(download.metadata.title)")
|
||||
}
|
||||
|
||||
func downloadQueue(_ queue: CKDownloadQueue, changedWithRemoval download: SSDownload) {
|
||||
func downloadQueue(_: CKDownloadQueue, changedWithRemoval download: SSDownload) {
|
||||
guard download.metadata.itemIdentifier == purchase.itemIdentifier,
|
||||
let status = download.status else {
|
||||
return
|
||||
|
|
|
@ -15,11 +15,11 @@ typealias SSPurchaseCompletion =
|
|||
extension SSPurchase {
|
||||
convenience init(adamId: UInt64, account: ISStoreAccount) {
|
||||
self.init()
|
||||
self.buyParameters =
|
||||
buyParameters =
|
||||
"productType=C&price=0&salableAdamId=\(adamId)&pricingParameters=STDRDL&pg=default&appExtVrsId=0"
|
||||
self.itemIdentifier = adamId
|
||||
self.accountIdentifier = account.dsID
|
||||
self.appleID = account.identifier
|
||||
itemIdentifier = adamId
|
||||
accountIdentifier = account.dsID
|
||||
appleID = account.identifier
|
||||
|
||||
let downloadMetadata = SSDownloadMetadata()
|
||||
downloadMetadata.kind = "software"
|
||||
|
|
|
@ -18,7 +18,7 @@ public struct AccountCommand: CommandProtocol {
|
|||
public init() {}
|
||||
|
||||
/// Runs the command.
|
||||
public func run(_ options: Options) -> Result<(), MASError> {
|
||||
public func run(_: Options) -> Result<(), MASError> {
|
||||
if let account = ISStoreAccount.primaryAccount {
|
||||
print(String(describing: account.identifier))
|
||||
} else {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import Foundation
|
||||
import Result
|
||||
|
||||
/// Displays app details. Uses the iTunes Lookup API:
|
||||
/// https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#lookup
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
/// Installs previously purchased apps from the Mac App Store.
|
||||
public struct InstallCommand: CommandProtocol {
|
||||
|
@ -54,7 +54,7 @@ public struct InstallOptions: OptionsProtocol {
|
|||
|
||||
public static func create(_ appIds: [Int]) -> (_ forceInstall: Bool) -> InstallOptions {
|
||||
return { forceInstall in
|
||||
return InstallOptions(appIds: appIds.map {UInt64($0)}, forceInstall: forceInstall)
|
||||
InstallOptions(appIds: appIds.map { UInt64($0) }, forceInstall: forceInstall)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public struct ListCommand: CommandProtocol {
|
|||
}
|
||||
|
||||
/// Runs the command.
|
||||
public func run(_ options: Options) -> Result<(), MASError> {
|
||||
public func run(_: Options) -> Result<(), MASError> {
|
||||
let products = appLibrary.installedApps
|
||||
if products.isEmpty {
|
||||
print("No installed apps found")
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
/// Command which installs the first search result. This is handy as many MAS titles
|
||||
/// can be long with embedded keywords.
|
||||
|
@ -89,7 +89,7 @@ public struct LuckyOptions: OptionsProtocol {
|
|||
|
||||
public static func create(_ appName: String) -> (_ forceInstall: Bool) -> LuckyOptions {
|
||||
return { forceInstall in
|
||||
return LuckyOptions(appName: appName, forceInstall: forceInstall)
|
||||
LuckyOptions(appName: appName, forceInstall: forceInstall)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public struct OpenCommand: CommandProtocol {
|
|||
public init(storeSearch: StoreSearch = MasStoreSearch(),
|
||||
openCommand: ExternalCommand = OpenSystemCommand()) {
|
||||
self.storeSearch = storeSearch
|
||||
self.systemOpen = openCommand
|
||||
systemOpen = openCommand
|
||||
}
|
||||
|
||||
/// Runs the command.
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
/// Command which displays a list of installed apps which have available updates
|
||||
/// ready to be installed from the Mac App Store.
|
||||
|
@ -27,7 +27,7 @@ public struct OutdatedCommand: CommandProtocol {
|
|||
}
|
||||
|
||||
/// Runs the command.
|
||||
public func run(_ options: Options) -> Result<(), MASError> {
|
||||
public func run(_: Options) -> Result<(), MASError> {
|
||||
let updateController = CKUpdateController.shared()
|
||||
let updates = updateController?.availableUpdates()
|
||||
for update in updates! {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
/// Kills several macOS processes as a means to reset the app store.
|
||||
public struct ResetCommand: CommandProtocol {
|
||||
|
@ -60,7 +60,7 @@ public struct ResetCommand: CommandProtocol {
|
|||
kill.launch()
|
||||
kill.waitUntilExit()
|
||||
|
||||
if kill.terminationStatus != 0 && options.debug {
|
||||
if kill.terminationStatus != 0, options.debug {
|
||||
let output = stderr.fileHandleForReading.readDataToEndOfFile()
|
||||
printInfo("killall failed:\r\n\(String(data: output, encoding: String.Encoding.utf8)!)")
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public struct SignInCommand: CommandProtocol {
|
|||
printInfo("Signing in to Apple ID: \(options.username)")
|
||||
|
||||
let password: String = {
|
||||
if options.password == "" && !options.dialog {
|
||||
if options.password == "", !options.dialog {
|
||||
return String(validatingUTF8: getpass("Password: "))!
|
||||
}
|
||||
return options.password
|
||||
|
@ -56,7 +56,7 @@ public struct SignInOptions: OptionsProtocol {
|
|||
|
||||
static func create(username: String) -> (_ password: String) -> (_ dialog: Bool) -> SignInOptions {
|
||||
return { password in { dialog in
|
||||
return SignInOptions(username: username, password: password, dialog: dialog)
|
||||
SignInOptions(username: username, password: password, dialog: dialog)
|
||||
} }
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
public struct SignOutCommand: CommandProtocol {
|
||||
public typealias Options = NoOptions<MASError>
|
||||
|
@ -18,7 +18,7 @@ public struct SignOutCommand: CommandProtocol {
|
|||
public init() {}
|
||||
|
||||
/// Runs the command.
|
||||
public func run(_ options: Options) -> Result<(), MASError> {
|
||||
public func run(_: Options) -> Result<(), MASError> {
|
||||
if #available(macOS 10.13, *) {
|
||||
let accountService: ISAccountService = ISServiceProxy.genericShared().accountService
|
||||
accountService.signOut()
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
import StoreFoundation
|
||||
|
||||
/// Command which uninstalls apps managed by the Mac App Store.
|
||||
|
@ -64,7 +64,7 @@ public struct UninstallOptions: OptionsProtocol {
|
|||
|
||||
static func create(_ appId: Int) -> (_ dryRun: Bool) -> UninstallOptions {
|
||||
return { dryRun in
|
||||
return UninstallOptions(appId: appId, dryRun: dryRun)
|
||||
UninstallOptions(appId: appId, dryRun: dryRun)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Result
|
||||
import CommerceKit
|
||||
import Result
|
||||
|
||||
/// Command which upgrades apps with new versions available in the Mac App Store.
|
||||
public struct UpgradeCommand: CommandProtocol {
|
||||
|
|
|
@ -18,7 +18,7 @@ public struct VersionCommand: CommandProtocol {
|
|||
public init() {}
|
||||
|
||||
/// Runs the command.
|
||||
public func run(_ options: Options) -> Result<(), MASError> {
|
||||
public func run(_: Options) -> Result<(), MASError> {
|
||||
let plist = Bundle.main.infoDictionary
|
||||
if let versionString = plist?["CFBundleShortVersionString"] {
|
||||
print(versionString)
|
||||
|
|
|
@ -41,7 +41,7 @@ public enum MASError: Error, CustomStringConvertible, Equatable {
|
|||
"\nFor more info see: " +
|
||||
"https://github.com/mas-cli/mas/issues/164"
|
||||
|
||||
case .signInFailed(let error):
|
||||
case let .signInFailed(error):
|
||||
if let error = error {
|
||||
return "Sign in failed: \(error.localizedDescription)"
|
||||
} else {
|
||||
|
@ -51,14 +51,14 @@ public enum MASError: Error, CustomStringConvertible, Equatable {
|
|||
case .alreadySignedIn:
|
||||
return "Already signed in"
|
||||
|
||||
case .purchaseFailed(let error):
|
||||
case let .purchaseFailed(error):
|
||||
if let error = error {
|
||||
return "Download request failed: \(error.localizedDescription)"
|
||||
} else {
|
||||
return "Download request failed"
|
||||
}
|
||||
|
||||
case .downloadFailed(let error):
|
||||
case let .downloadFailed(error):
|
||||
if let error = error {
|
||||
return "Download failed: \(error.localizedDescription)"
|
||||
} else {
|
||||
|
|
|
@ -33,8 +33,7 @@ public struct SearchResult: Decodable {
|
|||
trackCensoredName: String = "",
|
||||
trackName: String = "",
|
||||
trackViewUrl: String = "",
|
||||
version: String = ""
|
||||
) {
|
||||
version: String = "") {
|
||||
self.bundleId = bundleId
|
||||
self.currentVersionReleaseDate = currentVersionReleaseDate
|
||||
self.fileSizeBytes = fileSizeBytes
|
||||
|
|
|
@ -14,10 +14,10 @@ enum NetworkResult {
|
|||
extension NetworkResult: Equatable {
|
||||
static func == (lhs: NetworkResult, rhs: NetworkResult) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (let .success(data1), let .success(data2)):
|
||||
case let (.success(data1), .success(data2)):
|
||||
return data1 == data2
|
||||
|
||||
case (let .failure(error1), let .failure(error2)):
|
||||
case let (.failure(error1), .failure(error2)):
|
||||
return error1.localizedDescription == error2.localizedDescription
|
||||
|
||||
// case (.none, .none):
|
||||
|
|
|
@ -10,7 +10,7 @@ import Foundation
|
|||
|
||||
extension URLSession: NetworkSession {
|
||||
@objc open func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) {
|
||||
let task = dataTask(with: url) { (data, _, error) in
|
||||
let task = dataTask(with: url) { data, _, error in
|
||||
completionHandler(data, error)
|
||||
}
|
||||
task.resume()
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class AccountCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class HomeCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class InfoCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class InstallCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class ListCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class LuckyCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class OpenCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class OutdatedCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class ResetCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class SearchCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class SignInCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class SignOutCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class UninstallCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class UpgradeCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class VendorCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class VersionCommandSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -15,13 +15,13 @@ class AppLibraryMock: AppLibrary {
|
|||
///
|
||||
/// - Parameter bundleId: Bundle identifier of app.
|
||||
/// - Returns: Software Product of app if found; nil otherwise.
|
||||
public func installedApp(forBundleId bundleId: String) -> SoftwareProduct? {
|
||||
public func installedApp(forBundleId _: String) -> SoftwareProduct? {
|
||||
return nil
|
||||
}
|
||||
|
||||
func uninstallApp(app: SoftwareProduct) throws {
|
||||
if !installedApps.contains(where: { (product) -> Bool in
|
||||
return app.itemIdentifier == product.itemIdentifier
|
||||
app.itemIdentifier == product.itemIdentifier
|
||||
}) { throw MASError.notInstalled }
|
||||
|
||||
// Special case for testing where we pretend the trash command failed
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class MasStoreSearchSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
@ -25,7 +25,7 @@ class MasStoreSearchSpec: QuickSpec {
|
|||
expect(searchList.results.count) == 6
|
||||
} catch {
|
||||
let maserror = error as! MASError
|
||||
if case .jsonParsing(let nserror) = maserror {
|
||||
if case let .jsonParsing(nserror) = maserror {
|
||||
fail("\(maserror) \(nserror!)")
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class MasStoreSearchSpec: QuickSpec {
|
|||
}
|
||||
describe("store lookup") {
|
||||
it("can find slack") {
|
||||
let appId = 803453959
|
||||
let appId = 803_453_959
|
||||
let networkSession = NetworkSessionMockFromFile(responseFile: "lookup/slack.json")
|
||||
let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession))
|
||||
|
||||
|
@ -42,7 +42,7 @@ class MasStoreSearchSpec: QuickSpec {
|
|||
lookup = try storeSearch.lookup(app: appId)
|
||||
} catch {
|
||||
let maserror = error as! MASError
|
||||
if case .jsonParsing(let nserror) = maserror {
|
||||
if case let .jsonParsing(nserror) = maserror {
|
||||
fail("\(maserror) \(nserror!)")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
// Copyright © 2019 mas-cli. All rights reserved.
|
||||
//
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
/// Protocol minimal implementation
|
||||
struct StoreSearchForTesting: StoreSearch {
|
||||
func lookup(app appId: Int) throws -> SearchResult? { return nil }
|
||||
func search(for appName: String) throws -> SearchResultList { return SearchResultList(resultCount: 0, results: []) }
|
||||
func lookup(app _: Int) throws -> SearchResult? { return nil }
|
||||
func search(for _: String) throws -> SearchResultList { return SearchResultList(resultCount: 0, results: []) }
|
||||
}
|
||||
|
||||
class StoreSearchSpec: QuickSpec {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import XCTest
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
class MASErrorTestCase: XCTestCase {
|
||||
private let errorDomain = "MAS"
|
||||
|
@ -21,8 +21,8 @@ class MASErrorTestCase: XCTestCase {
|
|||
var localizedDescription: String {
|
||||
get { return "dummy value" }
|
||||
set {
|
||||
NSError.setUserInfoValueProvider(forDomain: errorDomain) { (error: Error, userInfoKey: String) -> Any? in
|
||||
return newValue
|
||||
NSError.setUserInfoValueProvider(forDomain: errorDomain) { (_: Error, _: String) -> Any? in
|
||||
newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
import Result
|
||||
|
||||
class SearchResultsFormatterSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -23,7 +23,7 @@ class NetworkSessionMock: NetworkSession {
|
|||
/// - url: unused
|
||||
/// - completionHandler: Closure which is delivered both data and error properties (only one should be non-nil)
|
||||
/// - Returns: Mock data task
|
||||
func dataTask(with url: URL, completionHandler: @escaping CompletionHandler) -> URLSessionDataTask {
|
||||
func dataTask(with _: URL, completionHandler: @escaping CompletionHandler) -> URLSessionDataTask {
|
||||
let data = self.data
|
||||
let error = self.error
|
||||
|
||||
|
@ -37,7 +37,7 @@ class NetworkSessionMock: NetworkSession {
|
|||
/// - Parameters:
|
||||
/// - url: unused
|
||||
/// - completionHandler: Closure which is delivered either data or an error.
|
||||
@objc func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) {
|
||||
@objc func loadData(from _: URL, completionHandler: @escaping (Data?, Error?) -> Void) {
|
||||
completionHandler(data, error)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class NetworkSessionMockFromFile: NetworkSessionMock {
|
|||
/// - Parameters:
|
||||
/// - url: unused
|
||||
/// - completionHandler: Closure which is delivered either data or an error.
|
||||
@objc override func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) {
|
||||
@objc override func loadData(from _: URL, completionHandler: @escaping (Data?, Error?) -> Void) {
|
||||
guard let fileURL = Bundle.jsonResponse(fileName: responseFile)
|
||||
else { fatalError("Unable to load file \(responseFile)") }
|
||||
|
||||
|
|
|
@ -10,13 +10,12 @@ import Foundation
|
|||
|
||||
/// Delegate for network requests initiated from tests.
|
||||
class TestURLSessionDelegate: NSObject, URLSessionDelegate {
|
||||
func urlSession(_ session: URLSession,
|
||||
func urlSession(_: URLSession,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: (URLSession.AuthChallengeDisposition,
|
||||
URLCredential?) -> Void) {
|
||||
|
||||
// For example, you may want to override this to accept some self-signed certs here.
|
||||
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust &&
|
||||
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
|
||||
Constants.selfSignedHosts.contains(challenge.protectionSpace.host) {
|
||||
// Allow the self-signed cert.
|
||||
let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
|
||||
|
|
|
@ -14,7 +14,7 @@ extension URLSessionConfiguration {
|
|||
/// newly created session configuration object, customised
|
||||
/// from the default to your requirements.
|
||||
class func testSessionConfiguration() -> URLSessionConfiguration {
|
||||
let config = self.default
|
||||
let config = `default`
|
||||
|
||||
// Eg we think 60s is too long a timeout time.
|
||||
config.timeoutIntervalForRequest = 20
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
//
|
||||
|
||||
@testable import MasKit
|
||||
import Result
|
||||
import Nimble
|
||||
import Result
|
||||
|
||||
/// Nimble predicate for result enum success case, no associated value
|
||||
func beSuccess() -> Predicate<Result<(), MASError>> {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
// Copyright © 2019 mas-cli. All rights reserved.
|
||||
//
|
||||
|
||||
import Quick
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
class OutputListenerSpec: QuickSpec {
|
||||
override func spec() {
|
||||
|
|
|
@ -31,7 +31,7 @@ typealias CoolClosure = (Int) -> Bool
|
|||
|
||||
// Use aliased parameter names when function parameters are ambiguous
|
||||
func yTown(some: Int, withCallback callback: CoolClosure) -> Bool {
|
||||
return CoolClosure(some)
|
||||
return callback(some)
|
||||
}
|
||||
|
||||
// It's OK to use $ variable references if the closure is very short and
|
||||
|
@ -40,7 +40,7 @@ let cool = yTown(5) { $0 == 6 }
|
|||
|
||||
// Use full variable names when closures are more complex
|
||||
let cool = yTown(5) { foo in
|
||||
if foo > 5 && foo < 0 {
|
||||
if foo > 5, foo < 0 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
|
|
@ -263,6 +263,7 @@
|
|||
B576FE3421E98AAE0016B39D /* StoreSearchSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreSearchSpec.swift; sourceTree = "<group>"; };
|
||||
B5793E28219BDD4800135B39 /* JSON */ = {isa = PBXFileReference; lastKnownFileType = folder; path = JSON; sourceTree = "<group>"; };
|
||||
B588CE0121DC89490047D305 /* ExternalCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalCommand.swift; sourceTree = "<group>"; };
|
||||
B592D8522201702A00A9C970 /* .swiftformat */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftformat; sourceTree = "<group>"; };
|
||||
B594B11F21D53A8200F3AC59 /* Uninstall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Uninstall.swift; sourceTree = "<group>"; };
|
||||
B594B12121D5416100F3AC59 /* ListCommandSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListCommandSpec.swift; sourceTree = "<group>"; };
|
||||
B594B12421D580BB00F3AC59 /* UninstallCommandSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UninstallCommandSpec.swift; sourceTree = "<group>"; };
|
||||
|
@ -409,6 +410,7 @@
|
|||
B55B3D9421EEA6A90009A1A5 /* .hound.yml */,
|
||||
B55B3D9821EEA6AA0009A1A5 /* .ruby-version */,
|
||||
B55B3D9B21EEBD6E0009A1A5 /* .shellcheck.yml */,
|
||||
B592D8522201702A00A9C970 /* .swiftformat */,
|
||||
B55B3D9521EEA6AA0009A1A5 /* .swiftlint.yml */,
|
||||
B55B3D9621EEA6AA0009A1A5 /* .travis.yml */,
|
||||
B55B3D8C21ED96FD0009A1A5 /* bin */,
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
// Copyright © 2015 Andrew Naylor. All rights reserved.
|
||||
//
|
||||
|
||||
import MasKit
|
||||
import Commandant
|
||||
import Foundation
|
||||
import MasKit
|
||||
|
||||
public struct StderrOutputStream: TextOutputStream {
|
||||
public mutating func write(_ string: String) {
|
||||
|
|
Loading…
Reference in a new issue