Audit 2026-05-17 V4. Ersetzt das hand-getippte Log.swift-Boilerplate
in jeder App durch einen Config-getriebenen Wrapper.
Neu:
- `ManaAppLog` — Factory fuer OSLog-Logger gegen ein ManaAppConfig.
Standard-Kategorien app/auth/api/db/web, plus `category("…")` fuer
app-spezifische Kategorien.
- `ManaAppConfig.appGroup: String?` (default nil) — Single-Source fuer
den App-Group-String, der heute in jeder App 3-4× hardcoded steht.
- `ManaAppConfig.logSubsystem: String` (default = keychainService) —
Subsystem fuer ManaAppLog.
Nichts breaking — beide neuen Felder haben Default-Implementations,
DefaultManaAppConfig.init hat zwei zusaetzliche optionale Parameter.
Tests: 4 neue ManaAppConfig-Tests + 5 neue ManaAppLog-Tests.
85/85 gruen (vorher 76/76).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.2 KiB
Swift
65 lines
2.2 KiB
Swift
import Foundation
|
|
import Testing
|
|
@testable import ManaCore
|
|
|
|
@Suite("ManaAppConfig")
|
|
struct ManaAppConfigTests {
|
|
@Test("DefaultManaAppConfig setzt Felder")
|
|
func defaultSetsFields() throws {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.memoro",
|
|
keychainAccessGroup: "TEAMID.ev.mana.shared"
|
|
)
|
|
#expect(config.authBaseURL.absoluteString == "https://auth.mana.how")
|
|
#expect(config.keychainService == "ev.mana.memoro")
|
|
#expect(config.keychainAccessGroup == "TEAMID.ev.mana.shared")
|
|
}
|
|
|
|
@Test("AccessGroup ist optional")
|
|
func accessGroupOptional() {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.cards"
|
|
)
|
|
#expect(config.keychainAccessGroup == nil)
|
|
}
|
|
|
|
@Test("AppGroup ist optional, default nil")
|
|
func appGroupDefaultsNil() {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.cards"
|
|
)
|
|
#expect(config.appGroup == nil)
|
|
}
|
|
|
|
@Test("AppGroup wird durchgereicht wenn gesetzt")
|
|
func appGroupPassedThrough() {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.cards",
|
|
appGroup: "group.ev.mana.cards"
|
|
)
|
|
#expect(config.appGroup == "group.ev.mana.cards")
|
|
}
|
|
|
|
@Test("LogSubsystem default = keychainService")
|
|
func logSubsystemDefaultsToKeychainService() {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.cards"
|
|
)
|
|
#expect(config.logSubsystem == "ev.mana.cards")
|
|
}
|
|
|
|
@Test("LogSubsystem kann explizit überschrieben werden")
|
|
func logSubsystemOverride() {
|
|
let config = DefaultManaAppConfig(
|
|
authBaseURL: URL(string: "https://auth.mana.how")!,
|
|
keychainService: "ev.mana.cards",
|
|
logSubsystem: "ev.mana.cards.debug"
|
|
)
|
|
#expect(config.logSubsystem == "ev.mana.cards.debug")
|
|
}
|
|
}
|