mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-21 22:30:46 +08:00
27 lines
1.1 KiB
Swift
27 lines
1.1 KiB
Swift
import XCTest
|
|
@testable import PaopaoLocationSpoofer
|
|
|
|
final class RuntimeLogStoreTests: XCTestCase {
|
|
func testRetentionCutoffIsExactlyThreeDays() {
|
|
let now = Date(timeIntervalSince1970: 1_800_000_000)
|
|
|
|
XCTAssertEqual(
|
|
RuntimeLogStore.retentionCutoff(now: now),
|
|
now.addingTimeInterval(-3 * 24 * 60 * 60)
|
|
)
|
|
}
|
|
|
|
func testRetentionKeepsCutoffAndNewerEntriesOnly() {
|
|
let now = Date(timeIntervalSince1970: 1_800_000_000)
|
|
let cutoff = RuntimeLogStore.retentionCutoff(now: now)
|
|
let expired = RuntimeLogEntry(timestamp: cutoff.addingTimeInterval(-0.001), source: "APP", level: .info, category: "Test", message: "expired")
|
|
let boundary = RuntimeLogEntry(timestamp: cutoff, source: "APP", level: .info, category: "Test", message: "boundary")
|
|
let recent = RuntimeLogEntry(timestamp: now, source: "CORE", level: .warning, category: "Proxy", message: "recent")
|
|
|
|
XCTAssertEqual(
|
|
RuntimeLogStore.retainedEntries([expired, boundary, recent], now: now),
|
|
[boundary, recent]
|
|
)
|
|
}
|
|
}
|