Template support for input parameters #4
38
Sources/Library/Tasks/CreateFoldersTask.swift
Normal file
38
Sources/Library/Tasks/CreateFoldersTask.swift
Normal file
@ -0,0 +1,38 @@
|
||||
import Foundation
|
||||
|
||||
public struct CreateFoldersTask {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let fileService: FileServicing
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
public init(fileService: FileServicing) {
|
||||
self.fileService = fileService
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - String+Constants
|
||||
|
||||
private extension String {
|
||||
static let folderApp = "Sources/App"
|
||||
static let folderAppInfrastructure = "Sources/AppInfrastructure"
|
||||
static let folderAppTestCases = "Tests/App/Cases"
|
||||
static let folderAppTestSources = "Tests/App/Sources"
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
public struct CreateProjectTask {
|
||||
|
||||
}
|
45
Tests/Library/Cases/Tasks/CreateFoldersTaskTests.swift
Normal file
45
Tests/Library/Cases/Tasks/CreateFoldersTaskTests.swift
Normal file
@ -0,0 +1,45 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct CreateFoldersTaskTests {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let spy = FileServiceSpy()
|
||||
|
||||
// MARK: Functions tests
|
||||
|
||||
@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 service = FileServiceMock(
|
||||
currentFolder: .someCurrentFolder,
|
||||
actions: [
|
||||
.createFolder(folderApp),
|
||||
.createFolder(folderAppInfrastructure),
|
||||
.createFolder(folderTestSources),
|
||||
.createFolder(folderTestCases),
|
||||
],
|
||||
spy: spy
|
||||
)
|
||||
|
||||
let createFolders = CreateFoldersTask(fileService: service)
|
||||
|
||||
// WHEN
|
||||
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))
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import ColibriLibrary
|
||||
import Testing
|
||||
|
||||
struct CreateProjectTaskTests {
|
||||
|
||||
@Test(.disabled())
|
||||
func something() async throws {
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
import ColibriLibrary
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct CreateRootFolderTaskTests {
|
||||
|
||||
// MARK: Functions tests
|
||||
@ -84,8 +85,8 @@ private extension String {
|
||||
// MARK: - URL+Constants
|
||||
|
||||
private extension URL {
|
||||
static let someCurrentProjectFolder = URL.someCurrentFolder.appending(component: String.someProjectName)
|
||||
static let someDotProjectFolder = URL.someDotFolder.appending(component: String.someProjectName)
|
||||
static let someNewProjectFolder = URL.someNewFolder.appending(component: String.someProjectName)
|
||||
static let someTildeProjectFolder = URL.someTildeFolder.appending(component: String.someProjectName)
|
||||
static let someCurrentProjectFolder = URL.someCurrentFolder.appendingPath(.someProjectName)
|
||||
static let someDotProjectFolder = URL.someDotFolder.appendingPath(.someProjectName)
|
||||
static let someNewProjectFolder = URL.someNewFolder.appendingPath(.someProjectName)
|
||||
static let someTildeProjectFolder = URL.someTildeFolder.appendingPath(.someProjectName)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user