Template support for input parameters #4

Merged
javier merged 81 commits from feature/arguments-templating into main 2025-02-17 22:11:06 +00:00
Showing only changes of commit a7be1ec0b0 - Show all commits

View File

@ -0,0 +1,84 @@
import ColibriLibrary
import Foundation
struct FileServiceMock {
// MARK: Properties
private let action: Action?
private let folder: URL
private weak var spy: FileServiceSpy?
// MARK: Initialisers
init(
currentFolder: URL,
action: Action? = nil,
spy: FileServiceSpy? = nil
) {
self.action = action
self.folder = currentFolder
self.spy = spy
}
}
// MARK: - FileServicing
extension FileServiceMock: FileServicing {
// MARK: Computed
var currentFolder: URL {
get async { folder }
}
// MARK: Functions
func createFolder(at url: URL) async throws(FileServiceError) {
switch action {
case .error(let error):
throw error
case let .createFolder(url):
try await spy?.createFolder(at: url)
default:
break
}
}
func delete(at url: URL) async throws(FileServiceError) {
switch action {
case .error(let error):
throw error
case let .delete(url):
try await spy?.delete(at: url)
default:
break
}
}
func exists(at url: URL) async throws(FileServiceError) -> Bool {
switch action {
case .error(let error):
throw error
case let .exists(url, exists):
try await spy?.exists(at: url)
return exists
default:
return false
}
}
}
// MARK: - Enumerations
extension FileServiceMock {
enum Action {
case createFolder(URL)
case delete(URL)
case error(FileServiceError)
case exists(URL, Bool)
}
}