learning_ai_common_plat/packages/swift-platform-sdk/Tests/BLFeatureFlagClientTests.swift
saravanakumardb1 933390e89b feat(swift-sdk): add ByteLystPlatform unified entry point + 5 new test files (4.1)
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
2026-03-19 21:05:58 -07:00

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
}
}