mirror of
https://github.com/mas-cli/mas
synced 2024-11-21 19:23:01 +00:00
880843d8e6
Resolve #585 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
28 lines
640 B
Swift
28 lines
640 B
Swift
//
|
|
// MockNetworkSession
|
|
// 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 MockNetworkSession: 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)
|
|
}
|
|
}
|