mirror of
https://github.com/Homebrew/BrewUI.git
synced 2026-10-02 08:34:36 +08:00
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>
18 lines
565 B
Swift
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)
|
|
}
|
|
}
|
|
}
|