46 lines
926 B
Swift
46 lines
926 B
Swift
import Foundation
|
|
|
|
@testable import ColibriLibrary
|
|
|
|
final class FileServiceSpy {
|
|
|
|
// MARK: Properties
|
|
|
|
private(set) var actions: [Action] = []
|
|
|
|
}
|
|
|
|
// MARK: - FileServicing
|
|
|
|
extension FileServiceSpy: FileServicing {
|
|
var currentFolder: URL {
|
|
get async { .someCurrentFolder }
|
|
}
|
|
|
|
func createFolder(at url: URL) async throws (FileServiceError) {
|
|
actions.append(.folderCreated(url))
|
|
}
|
|
|
|
func delete(at url: URL) async throws (FileServiceError) {
|
|
actions.append(.itemDeleted(url))
|
|
}
|
|
|
|
@discardableResult
|
|
func exists(at url: URL) async throws (FileServiceError) -> Bool {
|
|
actions.append(.itemExists(url))
|
|
|
|
return .random()
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - Action
|
|
|
|
extension FileServiceSpy {
|
|
enum Action: Equatable {
|
|
case folderCreated(_ url: URL)
|
|
case itemDeleted(_ url: URL)
|
|
case itemExists(_ url: URL)
|
|
}
|
|
}
|