43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
import ConfigurationClient
|
|
import Dependencies
|
|
import FileClient
|
|
import Foundation
|
|
@_spi(Internal) import PlaybookClient
|
|
import ShellClient
|
|
import Testing
|
|
|
|
@Suite("PlaybookClientTests")
|
|
struct PlaybookClientTests {
|
|
|
|
@Test
|
|
func installation() async throws {
|
|
try await withDependencies {
|
|
$0.fileClient = .liveValue
|
|
$0.asyncShellClient = .liveValue
|
|
} operation: {
|
|
let tempDirectory = FileManager.default.temporaryDirectory
|
|
let pathUrl = tempDirectory.appending(path: "playbook")
|
|
let playbookClient = PlaybookClient.liveValue
|
|
|
|
let configuration = Configuration(playbook: .init(directory: pathUrl.cleanFilePath))
|
|
|
|
try? FileManager.default.removeItem(at: pathUrl)
|
|
try await playbookClient.installPlaybook(configuration)
|
|
let exists = FileManager.default.fileExists(atPath: pathUrl.cleanFilePath)
|
|
#expect(exists)
|
|
|
|
try FileManager.default.removeItem(at: pathUrl)
|
|
}
|
|
}
|
|
|
|
@Test(arguments: [
|
|
(Configuration(), PlaybookClient.Constants.defaultInstallationPath),
|
|
(Configuration(playbook: .init(directory: "playbook")), "playbook")
|
|
])
|
|
func playbookDirectory(configuration: Configuration, expected: String) async throws {
|
|
let client = PlaybookClient.liveValue
|
|
let result = try await client.playbookDirectory(configuration)
|
|
#expect(result == expected)
|
|
}
|
|
}
|