Improved the naming of the functions for the FileServicing protocol in the library target.
This commit is contained in:
@@ -42,7 +42,7 @@ final class FileServiceMock {
|
||||
// MARK: - FileServicing
|
||||
|
||||
extension FileServiceMock: FileServicing {
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var currentFolder: URL {
|
||||
@@ -51,40 +51,40 @@ extension FileServiceMock: FileServicing {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func createFolder(at url: URL) async throws(FileServiceError) {
|
||||
func createFolder(at location: URL) async throws (FileServiceError) {
|
||||
guard let nextAction else { return }
|
||||
|
||||
switch nextAction {
|
||||
case .error(let error):
|
||||
throw error
|
||||
case let .createFolder(url):
|
||||
try await spy?.createFolder(at: url)
|
||||
case let .createFolder(location):
|
||||
try await spy?.createFolder(at: location)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func delete(at url: URL) async throws(FileServiceError) {
|
||||
func deleteItem(at location: URL) async throws (FileServiceError) {
|
||||
guard let nextAction else { return }
|
||||
|
||||
switch nextAction {
|
||||
case .error(let error):
|
||||
throw error
|
||||
case let .delete(url):
|
||||
try await spy?.delete(at: url)
|
||||
case let .deleteItem(location):
|
||||
try await spy?.deleteItem(at: location)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func exists(at url: URL) async throws(FileServiceError) -> Bool {
|
||||
func isItemExists(at location: URL) async throws (FileServiceError) -> Bool {
|
||||
guard let nextAction else { return false }
|
||||
|
||||
switch nextAction {
|
||||
case .error(let error):
|
||||
throw error
|
||||
case let .exists(url, exists):
|
||||
try await spy?.exists(at: url)
|
||||
case let .isItemExists(location, exists):
|
||||
try await spy?.isItemExists(at: location)
|
||||
return exists
|
||||
default:
|
||||
return false
|
||||
@@ -114,8 +114,8 @@ private extension FileServiceMock {
|
||||
extension FileServiceMock {
|
||||
enum Action {
|
||||
case createFolder(URL)
|
||||
case delete(URL)
|
||||
case deleteItem(URL)
|
||||
case error(FileServiceError)
|
||||
case exists(URL, Bool)
|
||||
case isItemExists(URL, Bool)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,24 @@ final class FileServiceSpy {
|
||||
// MARK: - FileServicing
|
||||
|
||||
extension FileServiceSpy: FileServicing {
|
||||
|
||||
var currentFolder: URL {
|
||||
get async { .someCurrentFolder }
|
||||
}
|
||||
|
||||
func createFolder(at url: URL) async throws (FileServiceError) {
|
||||
actions.append(.folderCreated(url))
|
||||
}
|
||||
|
||||
func delete(at url: URL) async throws (FileServiceError) {
|
||||
actions.append(.itemDeleted(url))
|
||||
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 exists(at url: URL) async throws (FileServiceError) -> Bool {
|
||||
actions.append(.itemExists(url))
|
||||
func isItemExists(at location: URL) async throws (FileServiceError) -> Bool {
|
||||
actions.append(.itemExists(location))
|
||||
|
||||
return .random()
|
||||
}
|
||||
@@ -38,8 +41,8 @@ extension FileServiceSpy: FileServicing {
|
||||
|
||||
extension FileServiceSpy {
|
||||
enum Action: Equatable {
|
||||
case folderCreated(_ url: URL)
|
||||
case itemDeleted(_ url: URL)
|
||||
case itemExists(_ url: URL)
|
||||
case folderCreated(_ location: URL)
|
||||
case itemDeleted(_ location: URL)
|
||||
case itemExists(_ location: URL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user