codeburn/mac/Tests/CodeBurnMenubarTests/ClaudePlanRecorderTests.swift
Resham Joshi 97dc656d40
feat(menubar): show each Claude account inside the provider box (#1876)
* feat(claude): attribute usage to the account that was active

* fix(claude): identify by organization and keep the identity field under a filter

* test(claude): check the log file mode on POSIX only

* feat(menubar): show each Claude account inside the provider box

* fix(claude): record the plan only where the credential is already read

* feat(menubar): record the plan the quota poll already knows

* ci: run the checks

* test: keep real fs and child_process exports in the WSL spawn mocks
2026-11-05 15:54:39 +01:00

30 lines
1.1 KiB
Swift

import Foundation
import Testing
@testable import CodeBurnMenubar
@Suite("Claude plan recorder")
struct ClaudePlanRecorderTests {
@Test("hands the plan to the CLI only when it changed for that config dir")
func runsOnlyWhenChanged() {
let calls = Calls()
let recorder = ClaudePlanRecorder(run: { calls.append($0) })
recorder.record(plan: "Max 5x", configDir: "/u/.claude")
recorder.record(plan: "Max 5x", configDir: "/u/.claude")
recorder.record(plan: "Max 20x", configDir: "/u/.claude")
recorder.record(plan: "Max 20x", configDir: "/u/other")
#expect(calls.value == [
["identity", "plan", "--config-dir", "/u/.claude", "--plan", "Max 5x"],
["identity", "plan", "--config-dir", "/u/.claude", "--plan", "Max 20x"],
["identity", "plan", "--config-dir", "/u/other", "--plan", "Max 20x"],
])
}
}
private final class Calls: @unchecked Sendable {
private let lock = NSLock()
private var stored: [[String]] = []
var value: [[String]] { lock.withLock { stored } }
func append(_ call: [String]) { lock.withLock { stored.append(call) } }
}