test: add semver and gateway helpers coverage
This commit is contained in:
@@ -71,6 +71,11 @@ enum GatewayEnvironment {
|
||||
return Semver.parse(bundleVersion)
|
||||
}
|
||||
|
||||
// Exposed for tests so we can inject fake version checks without rewriting bundle metadata.
|
||||
static func expectedGatewayVersion(from versionString: String?) -> Semver? {
|
||||
Semver.parse(versionString)
|
||||
}
|
||||
|
||||
static func check() -> GatewayEnvironmentStatus {
|
||||
let expected = self.expectedGatewayVersion()
|
||||
let projectRoot = CommandResolver.projectRoot()
|
||||
|
||||
@@ -27,4 +27,9 @@ import Testing
|
||||
defer { UserDefaults.standard.removeObject(forKey: "gatewayPort") }
|
||||
#expect(GatewayEnvironment.gatewayPort() == 19999)
|
||||
}
|
||||
|
||||
@Test func expectedGatewayVersionFromStringUsesParser() {
|
||||
#expect(GatewayEnvironment.expectedGatewayVersion(from: "v9.1.2") == Semver(major: 9, minor: 1, patch: 2))
|
||||
#expect(GatewayEnvironment.expectedGatewayVersion(from: nil) == nil)
|
||||
}
|
||||
}
|
||||
|
||||
21
apps/macos/Tests/ClawdisIPCTests/SemverTests.swift
Normal file
21
apps/macos/Tests/ClawdisIPCTests/SemverTests.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
import Testing
|
||||
@testable import Clawdis
|
||||
|
||||
@Suite struct SemverTests {
|
||||
@Test func comparisonOrdersByMajorMinorPatch() {
|
||||
let a = Semver(major: 1, minor: 0, patch: 0)
|
||||
let b = Semver(major: 1, minor: 1, patch: 0)
|
||||
let c = Semver(major: 1, minor: 1, patch: 1)
|
||||
let d = Semver(major: 2, minor: 0, patch: 0)
|
||||
|
||||
#expect(a < b)
|
||||
#expect(b < c)
|
||||
#expect(c < d)
|
||||
#expect(d > a)
|
||||
}
|
||||
|
||||
@Test func descriptionMatchesParts() {
|
||||
let v = Semver(major: 3, minor: 2, patch: 1)
|
||||
#expect(v.description == "3.2.1")
|
||||
}
|
||||
}
|
||||
@@ -77,4 +77,10 @@ import Testing
|
||||
try? fm.removeItem(at: older)
|
||||
try? fm.removeItem(at: newer)
|
||||
}
|
||||
|
||||
@Test func gatewayEntrypointNilWhenMissing() {
|
||||
let tmp = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: true)
|
||||
#expect(CommandResolver.gatewayEntrypoint(in: tmp) == nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user