feat: Working on updates to sem var and git client.
This commit is contained in:
@@ -15,7 +15,7 @@ struct CliClientTests {
|
||||
try await run {
|
||||
@Dependency(\.cliClient) var client
|
||||
let output = try await client.build(.testOptions(target: target))
|
||||
#expect(output == "/baz/Sources/bar/foo")
|
||||
#expect(output == "/baz/Sources/bar/Version.swift")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ struct CliClientTests {
|
||||
} operation: {
|
||||
@Dependency(\.cliClient) var client
|
||||
let output = try await client.bump(type, .testOptions())
|
||||
#expect(output == "/baz/Sources/bar/foo")
|
||||
#expect(output == "/baz/Sources/bar/Version.swift")
|
||||
} assert: { string, _ in
|
||||
|
||||
#expect(string != nil)
|
||||
@@ -54,7 +54,7 @@ struct CliClientTests {
|
||||
try await run {
|
||||
@Dependency(\.cliClient) var client
|
||||
let output = try await client.generate(.testOptions(target: target))
|
||||
#expect(output == "/baz/Sources/bar/foo")
|
||||
#expect(output == "/baz/Sources/bar/Version.swift")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ struct CliClientTests {
|
||||
} operation: {
|
||||
@Dependency(\.cliClient) var client
|
||||
let output = try await client.update(.testOptions(dryRun: dryRun, target: target))
|
||||
#expect(output == "/baz/Sources/bar/foo")
|
||||
#expect(output == "/baz/Sources/bar/Version.swift")
|
||||
} assert: { string, _ in
|
||||
if dryRun {
|
||||
#expect(string == nil)
|
||||
@@ -75,6 +75,18 @@ struct CliClientTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(arguments: GitClient.Version.mocks)
|
||||
func gitVersionToSemVar(version: GitClient.Version) {
|
||||
let semVar = version.semVar
|
||||
if semVar != nil {
|
||||
#expect(semVar!.versionString(allowPrerelease: false) == "1.0.0")
|
||||
#expect(semVar!.versionString(allowPrerelease: true) == version.description)
|
||||
} else {
|
||||
let semVar = SemVar(preRelease: version.description)
|
||||
#expect(semVar.versionString(allowPrerelease: true) == "0.0.0-\(version.description)")
|
||||
}
|
||||
}
|
||||
|
||||
func run(
|
||||
setupDependencies: @escaping (inout DependencyValues) -> Void = { _ in },
|
||||
operation: @Sendable @escaping () async throws -> Void,
|
||||
@@ -86,7 +98,7 @@ struct CliClientTests {
|
||||
$0.logger.logLevel = .debug
|
||||
$0.fileClient = .capturing(captured)
|
||||
$0.fileClient.fileExists = { _ in false }
|
||||
$0.gitVersionClient = .init { _, _ in "1.0.0" }
|
||||
$0.gitClient = .mock(.tag("1.0.0"))
|
||||
$0.cliClient = .liveValue
|
||||
setupDependencies(&$0)
|
||||
} operation: {
|
||||
@@ -120,14 +132,12 @@ extension CliClient.SharedOptions {
|
||||
static func testOptions(
|
||||
gitDirectory: String? = "/baz",
|
||||
dryRun: Bool = false,
|
||||
fileName: String = "foo",
|
||||
target: String = "bar",
|
||||
logLevel: Logger.Level = .trace
|
||||
) -> Self {
|
||||
.init(
|
||||
gitDirectory: gitDirectory,
|
||||
dryRun: dryRun,
|
||||
fileName: fileName,
|
||||
target: target,
|
||||
logLevel: logLevel
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ final class GitVersionTests: XCTestCase {
|
||||
$0.logger.logLevel = .debug
|
||||
$0.logger = .liveValue
|
||||
$0.asyncShellClient = .liveValue
|
||||
$0.gitVersionClient = .liveValue
|
||||
$0.gitClient = .liveValue
|
||||
$0.fileClient = .liveValue
|
||||
}, operation: {
|
||||
super.invokeTest()
|
||||
@@ -27,7 +27,7 @@ final class GitVersionTests: XCTestCase {
|
||||
}
|
||||
|
||||
func test_live() async throws {
|
||||
@Dependency(\.gitVersionClient) var versionClient: GitVersionClient
|
||||
@Dependency(\.gitClient) var versionClient: GitClient
|
||||
|
||||
let version = try await versionClient.currentVersion(in: gitDir)
|
||||
print("VERSION: \(version)")
|
||||
@@ -35,24 +35,6 @@ final class GitVersionTests: XCTestCase {
|
||||
XCTAssertNotEqual(version, "blob")
|
||||
}
|
||||
|
||||
// func test_commands() throws {
|
||||
// @Dependency(\.asyncShellClient) var shellClient: ShellClient
|
||||
//
|
||||
// XCTAssertNoThrow(
|
||||
// try shellClient.background(
|
||||
// .gitCurrentBranch(gitDirectory: gitDir),
|
||||
// trimmingCharactersIn: .whitespacesAndNewlines
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// XCTAssertNoThrow(
|
||||
// try shellClient.background(
|
||||
// .gitCurrentSha(gitDirectory: gitDir),
|
||||
// trimmingCharactersIn: .whitespacesAndNewlines
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
|
||||
func test_file_client() async throws {
|
||||
try await withTemporaryDirectory { tmpDir in
|
||||
@Dependency(\.fileClient) var fileClient
|
||||
|
||||
Reference in New Issue
Block a user