Implemented the TerminalService service for the library target
This commit is contained in:
@@ -26,6 +26,7 @@ struct TemplateServiceTests {
|
||||
|
||||
@Test(arguments: [TemplateServiceError.serviceNotInitialized, .resourcePathNotFound, .templateNotFound, .contentNotRendered])
|
||||
func render(throws error: TemplateServiceError) async throws {
|
||||
// GIVEN
|
||||
let service = TemplateServiceMock(action: .error(error), spy: spy)
|
||||
|
||||
// WHEN
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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 = ""
|
||||
}
|
||||
Reference in New Issue
Block a user