Implemented the CopyFilesTask task in the library target.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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]))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user