feat: Updates to check if playbook is installed prior to running any of the commands, updates tests.

This commit is contained in:
2024-12-19 11:22:16 -05:00
committed by Michael Housh
parent 86dc084e7d
commit d1a47e2ac6
5 changed files with 39 additions and 5 deletions

View File

@@ -23,7 +23,11 @@ struct FileClientTests {
let fileClient = FileClient.liveValue
let vaultFilePath = url.appending(path: fileName)
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#if os(Linux)
_ = FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#else
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#endif
let output = try await fileClient.findVaultFile(url)!
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)
@@ -43,7 +47,11 @@ struct FileClientTests {
try await fileClient.createDirectory(subDir)
let vaultFilePath = subDir.appending(path: fileName)
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#if os(Linux)
_ = FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#else
FileManager.default.createFile(atPath: vaultFilePath.cleanFilePath, contents: nil)
#endif
let output = try await fileClient.findVaultFile(url)!
#expect(output.cleanFilePath == vaultFilePath.cleanFilePath)

View File

@@ -145,6 +145,7 @@ struct PlaybookClientTests: TestCase {
@Test
func generateTemplate() async throws {
try await withCapturingCommandClient("generateTemplate") {
$0.fileClient.isDirectory = { _ in true }
$0.configurationClient = .mock()
$0.playbookClient = .liveValue
} run: {
@@ -180,6 +181,7 @@ struct PlaybookClientTests: TestCase {
operation: @Sendable @escaping () async throws -> Void
) async rethrows {
try await withDependencies {
$0.fileClient.isDirectory = { _ in true }
$0.configurationClient = .mock(configuration)
$0.commandClient = .capturing(capturing)
$0.playbookClient = .liveValue