feat: Adds more tests for cli-client.

This commit is contained in:
2024-12-11 17:03:43 -05:00
parent c1a14ea855
commit d9e91538fb
3 changed files with 79 additions and 103 deletions

View File

@@ -58,7 +58,7 @@ public extension CliClient {
try await runCommand(
quiet: options.quiet,
shell: options.shell.shellOrDefault,
shell: options.shell.orDefault,
arguments
)
}
@@ -95,13 +95,14 @@ public extension CliClient {
try await runCommand(
quiet: options.quiet,
shell: options.shell.shellOrDefault,
shell: options.shell.orDefault,
arguments
)
}
}
private extension ConfigurationClient {
@_spi(Internal)
public extension ConfigurationClient {
func ensuredConfiguration(_ optionalConfig: Configuration?) async throws -> Configuration {
guard let config = optionalConfig else {
return try await findAndLoad()
@@ -110,7 +111,8 @@ private extension ConfigurationClient {
}
}
private extension Configuration {
@_spi(Internal)
public extension Configuration {
func ensuredPlaybookDirectory(_ optionalDirectory: String?) throws -> String {
guard let directory = optionalDirectory else {
@@ -123,15 +125,16 @@ private extension Configuration {
}
}
private extension Optional where Wrapped == String {
var shellOrDefault: ShellCommand.Shell {
@_spi(Internal)
public extension Optional where Wrapped == String {
var orDefault: ShellCommand.Shell {
guard let shell = self else { return .zsh(useDashC: true) }
return .custom(path: shell, useDashC: true)
}
}
private func ensuredInventoryPath(
@_spi(Internal)
public func ensuredInventoryPath(
_ optionalInventoryPath: String?,
configuration: Configuration,
playbookDirectory: String
@@ -145,7 +148,8 @@ private func ensuredInventoryPath(
return path
}
private extension FileClient {
@_spi(Internal)
public extension FileClient {
func ensuredVaultFilePath(_ optionalPath: String?) async throws -> String {
guard let path = optionalPath else {