Template support for input parameters #4
12
Library/Sources/Internal/Enumerations/Folder.swift
Normal file
12
Library/Sources/Internal/Enumerations/Folder.swift
Normal file
@ -0,0 +1,12 @@
|
||||
enum Folder: String {
|
||||
case app = "App/Sources"
|
||||
case libraryPublic = "Library/Sources/Public"
|
||||
case libraryInternal = "Library/Sources/Internal"
|
||||
case testCasesPublic = "Test/Sources/Cases/Public"
|
||||
case testCasesInternal = "Test/Sources/Cases/Internal"
|
||||
case testHelpers = "Test/Sources/Helpers"
|
||||
}
|
||||
|
||||
// MARK: - CaseIterable
|
||||
|
||||
extension Folder: CaseIterable {}
|
@ -15,7 +15,7 @@ public struct CreateFoldersTask {
|
||||
// MARK: Functions
|
||||
|
||||
public func callAsFunction(at rootFolder: URL) async throws {
|
||||
let folders = Self.foldersToCreate.map { rootFolder.appendingPath($0) }
|
||||
let folders = Folder.allCases.map { rootFolder.appendingPath($0.rawValue) }
|
||||
|
||||
for folder in folders {
|
||||
try await fileService.createFolder(at: folder)
|
||||
@ -23,18 +23,3 @@ public struct CreateFoldersTask {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
extension CreateFoldersTask {
|
||||
|
||||
// MARK: Constants
|
||||
|
||||
static let foldersToCreate: [String] = [
|
||||
"Sources/App",
|
||||
"Sources/AppInfrastructure",
|
||||
"Tests/App/Cases",
|
||||
"Tests/App/Sources"
|
||||
]
|
||||
|
||||
}
|
||||
|
@ -14,24 +14,36 @@ struct CreateFoldersTaskTests {
|
||||
@Test(arguments: [URL.someCurrentFolder, .someDotFolder, .someTildeFolder])
|
||||
func createFolders(with rootFolder: URL) async throws {
|
||||
// GIVEN
|
||||
let folders = CreateFoldersTask.foldersToCreate.map { rootFolder.appendingPath($0) }
|
||||
let actions: [FileServiceMock.Action] = folders.map { .createFolder($0) }
|
||||
let folders = Folder.allCases.map { rootFolder.appendingPath($0.rawValue) }
|
||||
let actions = folders.map { FileServiceMock.Action.createFolder($0) }
|
||||
|
||||
let service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
actions: actions,
|
||||
spy: spy
|
||||
)
|
||||
|
||||
let createFolders = CreateFoldersTask(fileService: service)
|
||||
let createFolders = task(actions: actions)
|
||||
|
||||
// WHEN
|
||||
try await createFolders(at: rootFolder)
|
||||
|
||||
// THEN
|
||||
#expect(spy.actions.count == actions.count)
|
||||
|
||||
for index in actions.indices {
|
||||
#expect(spy.actions[index] == .folderCreated(folders[index]))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private extension CreateFoldersTaskTests {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func task(actions: [FileServiceMock.Action]) -> CreateFoldersTask {
|
||||
.init(fileService: FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
actions: actions,
|
||||
spy: spy
|
||||
))
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user