mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-08-08 06:56:10 +00:00
test: assert composer draft map stays within maxDraftCount
Newest keys win when the store is already full so prefs cannot grow without bound.
This commit is contained in:
parent
8090d9421d
commit
c887c313cd
@ -62,3 +62,15 @@ struct ComposerDraftStoreTests {
|
||||
#expect(defaults.object(forKey: ComposerDraftStore.storageKey) == nil)
|
||||
}
|
||||
}
|
||||
|
||||
@Test func maxDraftCountEvictsSurplusKeys() {
|
||||
let defaults = makeDefaults()
|
||||
for index in 0..<ComposerDraftStore.maxDraftCount {
|
||||
ComposerDraftStore.save("d\(index)", for: .location(geohash: String(format: "gh%04d", index)), in: defaults)
|
||||
}
|
||||
ComposerDraftStore.save("newest", for: .mesh, in: defaults)
|
||||
let map = defaults.dictionary(forKey: ComposerDraftStore.storageKey) as? [String: String] ?? [:]
|
||||
#expect(map.count == ComposerDraftStore.maxDraftCount)
|
||||
#expect(map["mesh"] == "newest")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user