Implemented the "copyFile(from: to: )" function for the FileService service in the library target.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user