Template support for input parameters #4
@ -15,19 +15,30 @@ public struct CreateFoldersTask {
|
||||
// MARK: Functions
|
||||
|
||||
public func callAsFunction(at rootFolder: URL) async throws {
|
||||
let folderApp = rootFolder.appendingPath(.folderApp)
|
||||
let folderAppInfrastructure = rootFolder.appendingPath(.folderAppInfrastructure)
|
||||
let folderAppTestCases = rootFolder.appendingPath(.folderAppTestCases)
|
||||
let folderAppTestSources = rootFolder.appendingPath(.folderAppTestSources)
|
||||
|
||||
try await fileService.createFolder(at: folderApp)
|
||||
try await fileService.createFolder(at: folderAppInfrastructure)
|
||||
try await fileService.createFolder(at: folderAppTestCases)
|
||||
try await fileService.createFolder(at: folderAppTestSources)
|
||||
let folders = Self.foldersToCreate.map { rootFolder.appendingPath($0) }
|
||||
|
||||
for folder in folders {
|
||||
try await fileService.createFolder(at: folder)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
extension CreateFoldersTask {
|
||||
|
||||
// MARK: Constants
|
||||
|
||||
static let foldersToCreate: [String] = [
|
||||
.folderApp,
|
||||
.folderAppInfrastructure,
|
||||
.folderAppTestCases,
|
||||
.folderAppTestSources
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
// MARK: - String+Constants
|
||||
|
||||
private extension String {
|
||||
|
@ -14,19 +14,12 @@ struct CreateFoldersTaskTests {
|
||||
@Test(arguments: [URL.someCurrentFolder, .someDotFolder, .someTildeFolder])
|
||||
func createFolders(with rootFolder: URL) async throws {
|
||||
// GIVEN
|
||||
let folderApp = rootFolder.appendingPath("Sources/App")
|
||||
let folderAppInfrastructure = rootFolder.appendingPath("Sources/AppInfrastructure")
|
||||
let folderTestSources = rootFolder.appendingPath("Test/App/Sources")
|
||||
let folderTestCases = rootFolder.appendingPath("Test/App/Cases")
|
||||
|
||||
let folders = CreateFoldersTask.foldersToCreate.map { rootFolder.appendingPath($0) }
|
||||
let actions: [FileServiceMock.Action] = folders.map { .createFolder($0) }
|
||||
|
||||
let service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
actions: [
|
||||
.createFolder(folderApp),
|
||||
.createFolder(folderAppInfrastructure),
|
||||
.createFolder(folderTestSources),
|
||||
.createFolder(folderTestCases),
|
||||
],
|
||||
actions: actions,
|
||||
spy: spy
|
||||
)
|
||||
|
||||
@ -36,10 +29,9 @@ struct CreateFoldersTaskTests {
|
||||
try await createFolders(at: rootFolder)
|
||||
|
||||
// THEN
|
||||
#expect(spy.actions[0] == .folderCreated(folderApp))
|
||||
#expect(spy.actions[1] == .folderCreated(folderAppInfrastructure))
|
||||
#expect(spy.actions[2] == .folderCreated(folderTestSources))
|
||||
#expect(spy.actions[3] == .folderCreated(folderTestCases))
|
||||
for index in actions.indices {
|
||||
#expect(spy.actions[index] == .folderCreated(folders[index]))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user