diff --git a/Tests/Library/Helpers/Spies/FileServiceSpy.swift b/Tests/Library/Helpers/Spies/FileServiceSpy.swift new file mode 100644 index 0000000..c149c14 --- /dev/null +++ b/Tests/Library/Helpers/Spies/FileServiceSpy.swift @@ -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") +}