Template support for input parameters (#4)
This PR contains the work done to support input parameters for the `create` command of the executable target, and to render content dynamically for the newly-generated project. Reviewed-on: #4 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #4.
This commit is contained in:
@@ -53,45 +53,37 @@ struct FileTests {
|
||||
private extension FileTests {
|
||||
enum Expectation {
|
||||
static let fileNames: [String] = [
|
||||
"App.swift",
|
||||
"AppArguments.swift",
|
||||
"AppBuilder.swift",
|
||||
"AppOptions.swift",
|
||||
"AppTests.swift",
|
||||
"Dockerfile",
|
||||
".dockerignore",
|
||||
"Environment+Properties.swift",
|
||||
".gitignore",
|
||||
"LICENSE",
|
||||
"LoggerLevel+Conformances.swift",
|
||||
"Package.swift",
|
||||
"README.md",
|
||||
"TestArguments.swift"
|
||||
]
|
||||
|
||||
static let filePaths: [String] = [
|
||||
"App/Sources/App.swift",
|
||||
"Library/Sources/Public/AppArguments.swift",
|
||||
"Library/Sources/Public/AppBuilder.swift",
|
||||
"App/Sources/AppOptions.swift",
|
||||
"Test/Sources/Cases/Public/AppTests.swift",
|
||||
"Dockerfile",
|
||||
".dockerignore",
|
||||
"Library/Sources/Internal/Environment+Properties.swift",
|
||||
".gitignore",
|
||||
"LICENSE",
|
||||
"Library/Sources/Internal/LoggerLevel+Conformances.swift",
|
||||
"Package.swift",
|
||||
"README.md",
|
||||
"Test/Sources/Helpers/TestArguments.swift"
|
||||
]
|
||||
|
||||
static let folders: [Folder] = [
|
||||
.app,
|
||||
.libraryPublic,
|
||||
.libraryPublic,
|
||||
.app,
|
||||
.testCasesPublic,
|
||||
.root,
|
||||
.root,
|
||||
.libraryInternal,
|
||||
@@ -99,17 +91,13 @@ private extension FileTests {
|
||||
.root,
|
||||
.libraryInternal,
|
||||
.root,
|
||||
.root,
|
||||
.testHelpers
|
||||
]
|
||||
|
||||
|
||||
static let resourcePaths: [String] = [
|
||||
"Resources/Files/Sources/App",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources/App",
|
||||
"Resources/Files/Sources/Test",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Library",
|
||||
@@ -117,9 +105,7 @@ private extension FileTests {
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Test"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct TemplateTests {
|
||||
|
||||
// MARK: Properties tests
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.fileNames))
|
||||
func fileName(for template: Template, expects fileName: String) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.fileName
|
||||
|
||||
// THEN
|
||||
#expect(result == fileName)
|
||||
}
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.filePaths))
|
||||
func filePath(for template: Template, expects filePath: String) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.filePath
|
||||
|
||||
// THEN
|
||||
#expect(result == filePath)
|
||||
}
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.folders))
|
||||
func folder(for template: Template, expects folder: Folder) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.folder
|
||||
|
||||
// THEN
|
||||
#expect(result == folder)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Expectations
|
||||
|
||||
private extension TemplateTests {
|
||||
enum Expectation {
|
||||
static let fileNames: [String] = [
|
||||
"App.swift",
|
||||
"AppTests.swift",
|
||||
"Package.swift",
|
||||
]
|
||||
|
||||
static let filePaths: [String] = [
|
||||
"App/Sources/App.swift",
|
||||
"Test/Sources/Cases/Public/AppTests.swift",
|
||||
"Package.swift",
|
||||
]
|
||||
|
||||
static let folders: [Folder] = [
|
||||
.app,
|
||||
.testCasesPublic,
|
||||
.root,
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user