Implemented the FileServiceSpy spy in the Tests target.

This commit is contained in:
Javier Cicchelli 2025-01-11 11:27:39 +01:00
parent 1d080cce45
commit 4b900818ec

View File

@ -0,0 +1,47 @@
import Foundation
@testable import ColibriLibrary
final class FileServiceSpy {
// MARK: Properties
private(set) var isCreateFolderCalled: Bool = false
private(set) var isDeleteCalled: Bool = false
private(set) var isExistsAtCalled: Bool = false
private(set) var urlCalled: URL?
}
// MARK: - FileServicing
extension FileServiceSpy: FileServicing {
var currentFolder: URL {
get async { .someCurrentFolder }
}
func createFolder(at url: URL) async throws(FileServiceError) {
isCreateFolderCalled = true
urlCalled = url
}
func delete(at url: URL) async throws(FileServiceError) {
isDeleteCalled = true
urlCalled = url
}
@discardableResult
func exists(at url: URL) async throws(FileServiceError) -> Bool {
isExistsAtCalled = true
urlCalled = url
return .random()
}
}
// MARK: - URL+Constants
private extension URL {
static let someCurrentFolder = URL(at: "some/current/folder")
}