91e75e620b
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
68 lines
2.0 KiB
Swift
68 lines
2.0 KiB
Swift
import Foundation
|
|
import Testing
|
|
import Virtualization
|
|
@testable import lume
|
|
|
|
@Test("VMVirtualizationService starts correctly")
|
|
func testVMVirtualizationServiceStart() async throws {
|
|
let service = MockVMVirtualizationService()
|
|
|
|
// Initial state
|
|
#expect(await service.state == .stopped)
|
|
#expect(await service.startCallCount == 0)
|
|
|
|
// Start service
|
|
try await service.start()
|
|
#expect(await service.state == .running)
|
|
#expect(await service.startCallCount == 1)
|
|
}
|
|
|
|
@Test("VMVirtualizationService stops correctly")
|
|
func testVMVirtualizationServiceStop() async throws {
|
|
let service = MockVMVirtualizationService()
|
|
|
|
// Start then stop
|
|
try await service.start()
|
|
try await service.stop()
|
|
|
|
#expect(await service.state == .stopped)
|
|
#expect(await service.stopCallCount == 1)
|
|
}
|
|
|
|
@Test("VMVirtualizationService handles pause and resume")
|
|
func testVMVirtualizationServicePauseResume() async throws {
|
|
let service = MockVMVirtualizationService()
|
|
|
|
// Start and pause
|
|
try await service.start()
|
|
try await service.pause()
|
|
#expect(await service.state == .paused)
|
|
#expect(await service.pauseCallCount == 1)
|
|
|
|
// Resume
|
|
try await service.resume()
|
|
#expect(await service.state == .running)
|
|
#expect(await service.resumeCallCount == 1)
|
|
}
|
|
|
|
@Test("VMVirtualizationService handles operation failures")
|
|
func testVMVirtualizationServiceFailures() async throws {
|
|
let service = MockVMVirtualizationService()
|
|
await service.configure(shouldFail: true)
|
|
|
|
// Test start failure
|
|
do {
|
|
try await service.start()
|
|
#expect(Bool(false), "Expected start to throw")
|
|
} catch let error as VMError {
|
|
switch error {
|
|
case .internalError(let message):
|
|
#expect(message == "Mock operation failed")
|
|
default:
|
|
#expect(Bool(false), "Unexpected error type: \(error)")
|
|
}
|
|
}
|
|
|
|
#expect(await service.state == .stopped)
|
|
#expect(await service.startCallCount == 1)
|
|
} |