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>
49 lines
1.2 KiB
Swift
49 lines
1.2 KiB
Swift
import ColibriLibrary
|
|
import Foundation
|
|
import Testing
|
|
|
|
struct TemplateServiceTests {
|
|
|
|
// MARK: Properties
|
|
|
|
private let spy = TemplateServiceSpy()
|
|
|
|
// MARK: Functions tests
|
|
|
|
@Test(arguments: [String.content])
|
|
func render(_ content: String) async throws {
|
|
// GIVEN
|
|
let service = TemplateServiceMock(action: .render(content), spy: spy)
|
|
|
|
// WHEN
|
|
let result = try await service.render([:], on: .template)
|
|
|
|
// THEN
|
|
#expect(result == content)
|
|
|
|
#expect(spy.actions.isEmpty == false)
|
|
}
|
|
|
|
@Test(arguments: [TemplateServiceError.serviceNotInitialized, .resourcePathNotFound, .templateNotFound, .contentNotRendered])
|
|
func render(throws error: TemplateServiceError) async throws {
|
|
// GIVEN
|
|
let service = TemplateServiceMock(action: .error(error), spy: spy)
|
|
|
|
// WHEN
|
|
// THEN
|
|
await #expect(throws: error) {
|
|
try await service.render([:], on: .template)
|
|
}
|
|
|
|
#expect(spy.actions.isEmpty == true)
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - String+Constants
|
|
|
|
private extension String {
|
|
static let content = ""
|
|
static let template = ""
|
|
}
|