feat: Adds playbook client
This commit is contained in:
@@ -3,6 +3,7 @@ import ConfigurationClient
|
||||
import Dependencies
|
||||
import FileClient
|
||||
import Foundation
|
||||
import PlaybookClient
|
||||
import ShellClient
|
||||
import Testing
|
||||
import TestSupport
|
||||
@@ -104,19 +105,19 @@ struct CliClientTests: TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func ensuredPlaybookDirectory() throws {
|
||||
let configuration = Configuration.mock
|
||||
let playbookDir = try configuration.ensuredPlaybookDirectory("playbook")
|
||||
#expect(playbookDir == "playbook")
|
||||
|
||||
do {
|
||||
_ = try configuration.ensuredPlaybookDirectory(nil)
|
||||
#expect(Bool(false))
|
||||
} catch {
|
||||
#expect(Bool(true))
|
||||
}
|
||||
}
|
||||
// @Test
|
||||
// func ensuredPlaybookDirectory() throws {
|
||||
// let configuration = Configuration.mock
|
||||
// let playbookDir = try configuration.ensuredPlaybookDirectory("playbook")
|
||||
// #expect(playbookDir == "playbook")
|
||||
//
|
||||
// do {
|
||||
// _ = try configuration.ensuredPlaybookDirectory(nil)
|
||||
// #expect(Bool(false))
|
||||
// } catch {
|
||||
// #expect(Bool(true))
|
||||
// }
|
||||
// }
|
||||
|
||||
@Test
|
||||
func shellOrDefault() {
|
||||
@@ -295,6 +296,7 @@ struct CliClientTests: TestCase {
|
||||
try await withTestLogger(key: key, logLevel: logLevel) {
|
||||
$0.configurationClient = .mock(configuration)
|
||||
$0.cliClient = .capturing(capturing)
|
||||
$0.playbookClient = .liveValue
|
||||
setupDependencies(&$0)
|
||||
} operation: {
|
||||
try await operation()
|
||||
|
||||
42
Tests/PlaybookClientTests/PlaybookClientTests.swift
Normal file
42
Tests/PlaybookClientTests/PlaybookClientTests.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user