colibri/Test/Sources/Helpers/Spies/FileServiceSpy.swift
Javier Cicchelli 9be8fa4a31 Basic project creation (#3)
This PR contains the work done to create a new *Hummingbird* project with very basic configuration from the _colibri_ executable, just like the project you could create with the [Hummingbird template](https://github.com/hummingbird-project/template) project in Github.

Reviewed-on: #3
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
2025-01-28 00:07:24 +00:00

52 lines
1.2 KiB
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 copyFile(from source: URL, to destination: URL) async throws (FileServiceError) {
actions.append(.fileCopied(source, destination))
}
func createFolder(at location: URL) async throws (FileServiceError) {
actions.append(.folderCreated(location))
}
func deleteItem(at location: URL) async throws (FileServiceError) {
actions.append(.itemDeleted(location))
}
@discardableResult
func isItemExists(at location: URL) async throws (FileServiceError) -> Bool {
actions.append(.itemExists(location))
return .random()
}
}
// MARK: - Action
extension FileServiceSpy {
enum Action: Equatable {
case fileCopied(_ source: URL, _ destination: URL)
case folderCreated(_ location: URL)
case itemDeleted(_ location: URL)
case itemExists(_ location: URL)
}
}