Improved the naming of the functions for the FileServicing protocol in the library target.
This commit is contained in:
@@ -27,29 +27,29 @@ struct FileServiceTests {
|
||||
// MARK: Functions tests
|
||||
|
||||
@Test(arguments: [URL.someNewFolder, .someNewFile])
|
||||
func createFolder(with url: URL) async throws {
|
||||
func createFolder(with location: URL) async throws {
|
||||
// GIVEN
|
||||
let service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
action: .createFolder(url),
|
||||
action: .createFolder(location),
|
||||
spy: spy
|
||||
)
|
||||
|
||||
// WHEN
|
||||
try await service.createFolder(at: url)
|
||||
try await service.createFolder(at: location)
|
||||
|
||||
// THEN
|
||||
#expect(spy.actions.count == 1)
|
||||
|
||||
let action = try #require(spy.actions.last)
|
||||
|
||||
#expect(action == .folderCreated(url))
|
||||
#expect(action == .folderCreated(location))
|
||||
}
|
||||
|
||||
@Test(arguments: zip([URL.someExistingFolder, .someExistingFile, .someRandomURL],
|
||||
[FileServiceError.urlAlreadyExists, .urlAlreadyExists, .urlNotFileURL]))
|
||||
[FileServiceError.itemAlreadyExists, .itemAlreadyExists, .itemNotFileURL]))
|
||||
func createFolder(
|
||||
with url: URL,
|
||||
with location: URL,
|
||||
throws error: FileServiceError
|
||||
) async throws {
|
||||
// GIVEN
|
||||
@@ -62,36 +62,36 @@ struct FileServiceTests {
|
||||
// WHEN
|
||||
// THEN
|
||||
await #expect(throws: error) {
|
||||
try await service.createFolder(at: url)
|
||||
try await service.createFolder(at: location)
|
||||
}
|
||||
|
||||
#expect(spy.actions.isEmpty == true)
|
||||
}
|
||||
|
||||
@Test(arguments: [URL.someNewFolder, .someNewFile])
|
||||
func delete(with url: URL) async throws {
|
||||
func deleteItem(with location: URL) async throws {
|
||||
// GIVEN
|
||||
let service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
action: .delete(url),
|
||||
action: .deleteItem(location),
|
||||
spy: spy
|
||||
)
|
||||
|
||||
// WHEN
|
||||
try await service.delete(at: url)
|
||||
try await service.deleteItem(at: location)
|
||||
|
||||
// THEN
|
||||
#expect(spy.actions.count == 1)
|
||||
|
||||
let action = try #require(spy.actions.last)
|
||||
|
||||
#expect(action == .itemDeleted(url))
|
||||
#expect(action == .itemDeleted(location))
|
||||
}
|
||||
|
||||
@Test(arguments: zip([URL.someNewFolder, .someNewFile, .someRandomURL],
|
||||
[FileServiceError.urlNotExists, .urlNotExists, .urlNotFileURL]))
|
||||
func delete(
|
||||
with url: URL,
|
||||
[FileServiceError.itemNotExists, .itemNotExists, .itemNotFileURL]))
|
||||
func deleteItem(
|
||||
with location: URL,
|
||||
throws error: FileServiceError
|
||||
) async throws {
|
||||
// GIVEN
|
||||
@@ -104,7 +104,7 @@ struct FileServiceTests {
|
||||
// WHEN
|
||||
// THEN
|
||||
await #expect(throws: error) {
|
||||
try await service.delete(at: url)
|
||||
try await service.deleteItem(at: location)
|
||||
}
|
||||
|
||||
#expect(spy.actions.isEmpty == true)
|
||||
@@ -112,31 +112,31 @@ struct FileServiceTests {
|
||||
|
||||
@Test(arguments: zip([URL.someExistingFolder, .someExistingFile, .someNewFolder, .someNewFile],
|
||||
[true, true, false, false]))
|
||||
func exists(
|
||||
with url: URL,
|
||||
func isItemExists(
|
||||
with location: URL,
|
||||
expects outcome: Bool
|
||||
) async throws {
|
||||
// GIVEN
|
||||
let service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
action: .exists(url, outcome),
|
||||
action: .isItemExists(location, outcome),
|
||||
spy: spy
|
||||
)
|
||||
|
||||
// WHEN
|
||||
let result = try await service.exists(at: url)
|
||||
let result = try await service.isItemExists(at: location)
|
||||
|
||||
// THEN
|
||||
#expect(result == outcome)
|
||||
|
||||
let action = try #require(spy.actions.last)
|
||||
|
||||
#expect(action == .itemExists(url))
|
||||
#expect(action == .itemExists(location))
|
||||
}
|
||||
|
||||
@Test(arguments: zip([URL.someRandomURL], [FileServiceError.urlNotFileURL]))
|
||||
func exists(
|
||||
with url: URL,
|
||||
@Test(arguments: zip([URL.someRandomURL], [FileServiceError.itemNotFileURL]))
|
||||
func isItemExists(
|
||||
with location: URL,
|
||||
throws error: FileServiceError
|
||||
) async throws {
|
||||
// GIVEN
|
||||
@@ -149,7 +149,7 @@ struct FileServiceTests {
|
||||
// WHEN
|
||||
// THEN
|
||||
await #expect(throws: error) {
|
||||
try await service.exists(at: url)
|
||||
try await service.isItemExists(at: location)
|
||||
}
|
||||
|
||||
#expect(spy.actions.isEmpty == true)
|
||||
|
||||
Reference in New Issue
Block a user