mas/Tests/masTests/Network/MockNetworkSession.swift
Ross Goldberg 880843d8e6
Rename *Mock as Mock*.
Resolve #585

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
2024-10-25 23:39:52 -04:00

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