colibri/Test/Sources/Cases/Public/Services/TemplateServiceTests.swift
Javier Cicchelli 212ca52279 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>
2025-02-17 22:11:05 +00:00

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 = ""
}