learning_ai_common_plat/packages/swift-platform-sdk/Tests/BLKeychainTests.swift
saravanakumardb1 78000cdf6a feat(swift-sdk): add ByteLystPlatformSDK — shared Swift package for all iOS/watchOS/macOS apps
Extracts duplicated platform integration code from ChronoMind + LysnrAI into a
single Swift Package. Eliminates ~1,100+ lines of copied code per product app.

Components:
- BLPlatformConfig — product-specific configuration (productId, baseURL, bundleId)
- BLPlatformClient — generic HTTP client with auth injection, x-request-id, timeout
- BLKeychain — Keychain CRUD for secure token storage
- BLTelemetryClient — telemetry queue + batch flush (matches @bytelyst/telemetry-client)
- BLAuthClient — full auth operations (matches @bytelyst/auth-client)
- BLFeatureFlagClient — feature flag polling from platform-service /flags/poll
- BLSyncEngine — generic offline-first sync with delta pull + batch push

Platforms: iOS 17+, watchOS 10+, macOS 14+
2026-02-28 22:12:20 -08:00

34 lines
1.1 KiB
Swift

import XCTest
@testable import ByteLystPlatformSDK
final class BLKeychainTests: XCTestCase {
private let service = "com.bytelyst.test"
override func tearDown() {
BLKeychain.delete(service: service, key: "test_key")
super.tearDown()
}
func testSaveAndRead() {
BLKeychain.save(service: service, key: "test_key", value: "hello")
XCTAssertEqual(BLKeychain.read(service: service, key: "test_key"), "hello")
}
func testReadNonExistent() {
XCTAssertNil(BLKeychain.read(service: service, key: "nonexistent"))
}
func testDelete() {
BLKeychain.save(service: service, key: "test_key", value: "hello")
BLKeychain.delete(service: service, key: "test_key")
XCTAssertNil(BLKeychain.read(service: service, key: "test_key"))
}
func testOverwrite() {
BLKeychain.save(service: service, key: "test_key", value: "first")
BLKeychain.save(service: service, key: "test_key", value: "second")
XCTAssertEqual(BLKeychain.read(service: service, key: "test_key"), "second")
}
}