Files
BrewUI/Sources/BrewCoreTestSupport/UserDefaultsTestSupport.swift
Graeme ArthurandClaude Opus 4.7 8d63c82f6f Migrate CLI, Networking, and RepositoriesLive tests to hostless targets
Split the next three layers into SPM test targets (BrewCLITests,
BrewNetworkingTests, BrewRepositoriesLiveTests), re-pointing @testable imports
at the owning modules and the support libs. Relocate the cross-target URLProtocol
session stub and the removePersistedKeys UserDefaults helper into
BrewCoreTestSupport, and move cache/concurrency integration tests down to the
layer they exercise. 127 tests across 25 suites pass via `swift test` hostless.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 16:27:55 +10:00

18 lines
565 B
Swift

//
// UserDefaultsTestSupport.swift
// BrewTests
//
import Foundation
public extension UserDefaults {
/// Removes every key in `UserDefaults.standard` (or whichever instance) that starts with
/// the given prefix. Used by tests that isolate state with a per-test prefix instead of a
/// suite name, so cleanup doesn't depend on `removePersistentDomain`.
func removePersistedKeys(withPrefix prefix: String) {
for key in dictionaryRepresentation().keys where key.hasPrefix(prefix) {
removeObject(forKey: key)
}
}
}