New source: - ByteLystPlatform.swift — unified entry point wiring all services (config, client, telemetry, flags, killSwitch, crashReporter, keychain, auditLog, auth) - BLKeychainAccessor — convenience wrapper binding BLKeychain to a bundleId - start(userId:) / stop() lifecycle for telemetry + flags + killSwitch New tests (5 files, ~25 test cases): - ByteLystPlatformTests — init, start/stop, idempotency, keychain accessor - BLPlatformConfigTests — default + custom init - BLKillSwitchClientTests — default state, reset - BLFeatureFlagClientTests — empty flags, unknown key, stop - BLTelemetryClientTests — installId stability, session rotation, track/flush Also: add .build/ and .swiftpm/ to .gitignore
32 lines
890 B
Swift
32 lines
890 B
Swift
import XCTest
|
|
@testable import ByteLystPlatformSDK
|
|
|
|
final class BLFeatureFlagClientTests: XCTestCase {
|
|
|
|
private func makeClient() -> BLFeatureFlagClient {
|
|
let config = BLPlatformConfig(
|
|
productId: "testapp",
|
|
baseURL: "http://localhost:4003",
|
|
bundleId: "com.bytelyst.test"
|
|
)
|
|
let platformClient = BLPlatformClient(config: config)
|
|
return BLFeatureFlagClient(config: config, client: platformClient)
|
|
}
|
|
|
|
func testDefaultFlagsEmpty() {
|
|
let client = makeClient()
|
|
XCTAssertEqual(client.allFlags().count, 0)
|
|
}
|
|
|
|
func testIsEnabledReturnsFalseForUnknownKey() {
|
|
let client = makeClient()
|
|
XCTAssertFalse(client.isEnabled("nonexistent_flag"))
|
|
}
|
|
|
|
func testStopDoesNotCrash() {
|
|
let client = makeClient()
|
|
client.stop()
|
|
client.stop() // Double stop
|
|
}
|
|
}
|