import Foundation import Testing @testable import ColibriLibrary struct CopyFilesTaskTests { // MARK: Properties private let spy = FileServiceSpy() // MARK: Functions tests @Test(arguments: zip([URL.someExistingFolder], [URL.someNewFolder])) func copyFiles(from source: URL, to destination: URL) async throws { // GIVEN let filesToCopy = CopyFilesTask.filesToCopy let destinations = filesToCopy.map { destination.appendingPath($0) } let sources = filesToCopy.map { source.appendingPath($0) } let actions = filesToCopy.indices.map { index -> FileServiceMock.Action in .copyItem(sources[index], destinations[index]) } let service = FileServiceMock( currentFolder: .someCurrentFolder, actions: actions, spy: spy ) let copyFiles = CopyFilesTask(fileService: service) // WHEN try await copyFiles(to: destination) // THEN #expect(spy.actions.count == actions.count) for index in actions.indices { #expect(spy.actions[index] == .itemCopied(sources[index], destinations[index])) } } }