Implemented the "actions" property for the FileServiceSpy spy in the tests target to support tracking multiple actions.
This commit is contained in:
@@ -6,10 +6,7 @@ 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?
|
||||
private(set) var actions: [Action] = []
|
||||
|
||||
}
|
||||
|
||||
@@ -20,22 +17,29 @@ extension FileServiceSpy: FileServicing {
|
||||
get async { .someCurrentFolder }
|
||||
}
|
||||
|
||||
func createFolder(at url: URL) async throws(FileServiceError) {
|
||||
isCreateFolderCalled = true
|
||||
urlCalled = url
|
||||
func createFolder(at url: URL) async throws (FileServiceError) {
|
||||
actions.append(.folderCreated(url))
|
||||
}
|
||||
|
||||
func delete(at url: URL) async throws(FileServiceError) {
|
||||
isDeleteCalled = true
|
||||
urlCalled = url
|
||||
func delete(at url: URL) async throws (FileServiceError) {
|
||||
actions.append(.itemDeleted(url))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func exists(at url: URL) async throws(FileServiceError) -> Bool {
|
||||
isExistsAtCalled = true
|
||||
urlCalled = url
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user