Files
Termind/FrameworkTests/MetricsCPUUsageTests.swift
T
Kaede Akino d115cc2df4 test: remove over-specified assertions and translation lock-ins
Drop assertions that could not fail in a meaningful way or that only
restated copy already validated by Scripts/check-localization.py.

- Screenshot suites asserted arbitrary PNG byte counts, which AGENTS.md
  forbids; the opt-in Attachment.record exports stay.
- AgentSkillTests compared a snapshot revision with itself.
- MetricsCPUUsageTests asserted point.cpu, an alias of cpuUsage.utilization
  already pinned by the sibling assertion in that test.
- TerminalTransportTests locked enum declaration order and localized
  display names; symbol distinctness now compares against allCases.count
  instead of a magic 4.
- AppLanguageTests transcribed catalogs that check-localization.py already
  enforces for coverage, format arguments, plurals and spacing. Locale
  routing, migration and fallback tests remain, with the Chinese fallback
  checks rewritten as relationships rather than literal copy.
2026-10-17 10:31:50 +08:00

31 lines
1.3 KiB
Swift

import Foundation
import TermindDomain
import Testing
@Suite
nonisolated struct MetricsCPUUsageTests {
private let before: [UInt64] = [100, 0, 100, 800, 0, 0, 0, 0, 90, 0]
private let after: [UInt64] = [120, 0, 110, 850, 15, 0, 0, 5, 110, 0]
@Test func aggregateAndCoreShareCounterBreakdownWithoutCountingGuestTwice() {
let point = MetricsCalculation.point(
previous: MetricsSample(uptime: 100, cpu: before, cpuCores: [7: before]),
current: MetricsSample(uptime: 102, cpu: after, cpuCores: [7: after]),
selection: MetricsSelection(id: UUID()), date: .now)
let expected = MetricsCPUUsage(utilization: 35, user: 20, system: 10, wait: 15, steal: 5, idle: 50)
#expect(point.cpuUsage == expected)
#expect(point.cpuCores == [MetricsCPUPoint(id: 7, usage: expected)])
}
@Test func newAndResetCoresRemainUnknownWithoutDiscardingAggregateUsage() {
let point = MetricsCalculation.point(
previous: MetricsSample(uptime: 100, cpu: before, cpuCores: [7: before]),
current: MetricsSample(uptime: 102, cpu: after, cpuCores: [7: [UInt64](repeating: 0, count: 8), 2: after]),
selection: MetricsSelection(id: UUID()), date: .now)
#expect(point.cpu == 35)
#expect(point.cpuCores == [MetricsCPUPoint(id: 2), MetricsCPUPoint(id: 7)])
}
}