colibri/Test/Sources/Cases/Public/Services/TerminalServiceTests.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

52 lines
1.4 KiB
Swift

import ColibriLibrary
import Foundation
import Testing
struct TerminalServiceTests {
// MARK: Properties
private let spy = TerminalServiceSpy()
// MARK: Functions
@Test(arguments: [URL.someNewFile], [[], ["--example"], ["--example", "--more", "--etc"]])
func run(with executableURL: URL, and arguments: [String]) async throws {
// GIVEN
let service = TerminalServiceMock(action: .run(executableURL, arguments), spy: spy)
// WHEN
let result = try await service.run(executableURL, arguments: arguments)
// THEN
#expect(result == .content)
#expect(spy.actions.isEmpty == false)
let action = try #require(spy.actions.last)
#expect(action == .ran(executableURL, arguments))
}
@Test(arguments: [TerminalServiceError.unexpected, .captured("Some captured error"), .output("Some output error")])
func run(throws error: TerminalServiceError) async throws {
// GIVEN
let service = TerminalServiceMock(action: .error(error), spy: spy)
// WHEN
// THEN
await #expect(throws: error) {
try await service.run(URL.someNewFile, arguments: [])
}
#expect(spy.actions.isEmpty == true)
}
}
// MARK: - String+Constants
private extension String {
static let content = ""
}