Signal-iOS/SignalServiceKit/tests/Util/RemoteConfigManagerTests.swift
Max Radermacher fec0b0417b
Use UUID.data instead of reimplementing its logic
Also add a few more tests for remote config buckets.
2022-09-06 12:41:25 -07:00

24 lines
958 B
Swift

//
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
import Foundation
import XCTest
@testable import SignalServiceKit
class RemoteConfigManagerTests: SSKBaseTestSwift {
func test_bucketCalculation() {
let testCases: [(String, String, UInt64, UInt64)] = [
("research.megaphone.1", "15b9729c-51ea-4ddb-b516-652befe78062", 1_000_000, 243_315),
("research.megaphone.2", "15b9729c-51ea-4ddb-b516-652befe78062", 1_000_000, 551_742),
("research.megaphone.1", "5f5b28bb-f485-4a0a-a85c-13fc047524b1", 1_000_000, 365_381),
("research.megaphone.1", "15b9729c-51ea-4ddb-b516-652befe78062", 100_000, 43_315)
]
for (key, uuidString, bucketSize, expectedBucket) in testCases {
let actualBucket = RemoteConfig.bucket(key: key, uuid: UUID(uuidString: uuidString)!, bucketSize: bucketSize)
XCTAssertEqual(actualBucket, expectedBucket)
}
}
}