mas/Tests/masTests/Network/NetworkSessionMock.swift
Ross Goldberg 3eaffa5c3e
Improve DocC.
Partial #592

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-10-23 06:17:43 -04:00

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)
}
}