Implemented the "copyFile(from: to: )" function for the FileService service in the library target.

This commit is contained in:
2025-01-18 01:07:52 +01:00
parent af4958a5e8
commit b8d5bea7ae
5 changed files with 26 additions and 17 deletions
@@ -28,26 +28,26 @@ struct FileServiceTests {
@Test(arguments: zip([URL.someExistingFile, .someExistingFolder],
[URL.someNewFile, .someNewFolder]))
func copyItem(from source: URL, to destination: URL) async throws {
func copyFile(from source: URL, to destination: URL) async throws {
// GIVEN
let service = FileServiceMock(
currentFolder: .someCurrentFolder,
action: .copyItem(source, destination),
action: .copyFile(source, destination),
spy: spy
)
// WHEN
try await service.copyItem(from: source, to: destination)
try await service.copyFile(from: source, to: destination)
// THENn
#expect(spy.actions.count == 1)
let action = try #require(spy.actions.last)
#expect(action == .itemCopied(source, destination))
#expect(action == .fileCopied(source, destination))
}
@Test(arguments: [FileServiceError.itemNotExists, .itemAlreadyExists, .itemNotCopied])
@Test(arguments: [FileServiceError.itemNotExists, .itemAlreadyExists, .itemEmptyData, .itemNotCopied])
func copyItem(throws error: FileServiceError) async throws {
// GIVEN
let service = FileServiceMock(
@@ -59,7 +59,7 @@ struct FileServiceTests {
// WHEN
// THEN
await #expect(throws: error) {
try await service.copyItem(from: .someExistingFile, to: .someNewFile)
try await service.copyFile(from: .someExistingFile, to: .someNewFile)
}
#expect(spy.actions.isEmpty == true)