feat: Integrates playbook client into hpa-executable.
This commit is contained in:
@@ -16,6 +16,10 @@ struct PlaybookClientTests: TestCase {
|
||||
.init(loggingOptions: loggingOptions)
|
||||
}
|
||||
|
||||
static let defaultPlaybookPath = "~/.local/share/hpa/playbook/main.yml"
|
||||
static let defaultInventoryPath = "~/.local/share/hpa/playbook/inventory.ini"
|
||||
static let mockVaultArg = Configuration.mock.vault.args![0]
|
||||
|
||||
@Test(.tags(.repository))
|
||||
func repositoryInstallation() async throws {
|
||||
try await withDependencies {
|
||||
@@ -65,9 +69,9 @@ struct PlaybookClientTests: TestCase {
|
||||
print(arguments)
|
||||
|
||||
#expect(arguments == [
|
||||
"ansible-playbook", "~/.local/share/hpa/playbook/main.yml",
|
||||
"--inventory", "~/.local/share/hpa/playbook/inventory.ini",
|
||||
configuration.vault.args!.first!,
|
||||
"ansible-playbook", Self.defaultPlaybookPath,
|
||||
"--inventory", Self.defaultInventoryPath,
|
||||
Self.mockVaultArg,
|
||||
"--tags", "build-project",
|
||||
"--extra-vars", "project_dir=/foo"
|
||||
])
|
||||
@@ -102,9 +106,9 @@ struct PlaybookClientTests: TestCase {
|
||||
logger.debug("\(arguments)")
|
||||
|
||||
#expect(arguments == [
|
||||
"ansible-playbook", "~/.local/share/hpa/playbook/main.yml",
|
||||
"--inventory", "~/.local/share/hpa/playbook/inventory.ini",
|
||||
configuration.vault.args!.first!,
|
||||
"ansible-playbook", Self.defaultPlaybookPath,
|
||||
"--inventory", Self.defaultInventoryPath,
|
||||
Self.mockVaultArg,
|
||||
"--tags", "setup-project",
|
||||
"--extra-vars", "project_dir=/project",
|
||||
"--extra-vars", json
|
||||
@@ -139,6 +143,33 @@ struct PlaybookClientTests: TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func generateTemplate() async throws {
|
||||
try await withCapturingCommandClient("generateTemplate") {
|
||||
$0.configurationClient = .mock()
|
||||
$0.playbookClient = .liveValue
|
||||
} run: {
|
||||
@Dependency(\.playbookClient) var playbookClient
|
||||
|
||||
try await playbookClient.run.generateTemplate(.init(
|
||||
shared: Self.sharedRunOptions,
|
||||
templateDirectory: "/template"
|
||||
))
|
||||
|
||||
} assert: { output in
|
||||
|
||||
let expected = [
|
||||
"ansible-playbook", Self.defaultPlaybookPath,
|
||||
"--inventory", Self.defaultInventoryPath,
|
||||
Self.mockVaultArg,
|
||||
"--tags", "repo-template",
|
||||
"--extra-vars", "output_dir=/template"
|
||||
]
|
||||
|
||||
#expect(output.arguments == expected)
|
||||
}
|
||||
}
|
||||
|
||||
func withMockConfiguration(
|
||||
_ capturing: CommandClient.CapturingClient,
|
||||
configuration: Configuration = .mock,
|
||||
|
||||
Reference in New Issue
Block a user