mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
3eaffa5c3e
Partial #592 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
28 lines
640 B
Swift
28 lines
640 B
Swift
//
|
|
// NetworkSessionMock
|
|
// masTests
|
|
//
|
|
// Created by Ben Chatelain on 11/13/18.
|
|
// Copyright © 2018 mas-cli. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import PromiseKit
|
|
|
|
@testable import mas
|
|
|
|
/// Mock NetworkSession for testing.
|
|
class NetworkSessionMock: NetworkSession {
|
|
// Properties that enable us to set exactly what data or error
|
|
// we want our mocked URLSession to return for any request.
|
|
var data: Data?
|
|
var error: Error?
|
|
|
|
func loadData(from _: URL) -> Promise<Data> {
|
|
guard let data else {
|
|
return Promise(error: error ?? MASError.noData)
|
|
}
|
|
|
|
return .value(data)
|
|
}
|
|
}
|