Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocked Configuration Rename #35

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/WebPushTesting/VAPIDConfiguration+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import WebPush

extension VAPID.Configuration {
/// A mocked configuration useful when testing with the library, since the mocked manager doesn't make use of it anyways.
public static let mocked = VAPID.Configuration(key: .mockedKey1, contactInformation: .email("[email protected]"))
public static let mockedConfiguration = VAPID.Configuration(key: .mockedKey1, contactInformation: .email("[email protected]"))
}
2 changes: 1 addition & 1 deletion Sources/WebPushTesting/WebPushManager+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension WebPushManager {
/// - messageHandler: A handler to receive messages or throw errors.
/// - Returns: A new manager suitable for mocking.
public static func makeMockedManager(
vapidConfiguration: VAPID.Configuration = .mocked,
vapidConfiguration: VAPID.Configuration = .mockedConfiguration,
// TODO: Add networkConfiguration for proxy, number of simultaneous pushes, etc…
logger: Logger? = nil,
messageHandler: @escaping @Sendable (
Expand Down
12 changes: 6 additions & 6 deletions Tests/WebPushTests/WebPushManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct WebPushManagerTests {

/// This is needed to cover the `uniquingKeysWith` safety call completely.
@Test func managerConstructsAValidKeyLookupFromQuestionableConfiguration() async throws {
var configuration = VAPID.Configuration.mocked
var configuration = VAPID.Configuration.mockedConfiguration
configuration.unsafeUpdateKeys(primaryKey: .mockedKey1, keys: [.mockedKey1], deprecatedKeys: [.mockedKey1])
let manager = WebPushManager(vapidConfiguration: configuration)
#expect(await manager.vapidKeyLookup == [.mockedKeyID1 : .mockedKey1])
Expand All @@ -105,7 +105,7 @@ struct WebPushManagerTests {

@Suite("VAPID Key Retrieval") struct VAPIDKeyRetrieval {
@Test func retrievesPrimaryKey() async {
let manager = WebPushManager(vapidConfiguration: .mocked)
let manager = WebPushManager(vapidConfiguration: .mockedConfiguration)
#expect(manager.nextVAPIDKeyID == .mockedKeyID1)
await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
Expand All @@ -116,7 +116,7 @@ struct WebPushManagerTests {
}

@Test func alwaysRetrievesPrimaryKey() async throws {
var configuration = VAPID.Configuration.mocked
var configuration = VAPID.Configuration.mockedConfiguration
try configuration.updateKeys(primaryKey: .mockedKey1, keys: [.mockedKey2], deprecatedKeys: [.mockedKey3])
let manager = WebPushManager(vapidConfiguration: configuration)
for _ in 0..<100_000 {
Expand All @@ -131,7 +131,7 @@ struct WebPushManagerTests {
}

@Test func retrievesFallbackKeys() async throws {
var configuration = VAPID.Configuration.mocked
var configuration = VAPID.Configuration.mockedConfiguration
try configuration.updateKeys(primaryKey: nil, keys: [.mockedKey1, .mockedKey2])
let manager = WebPushManager(vapidConfiguration: configuration)
var keyCounts: [VAPID.Key.ID : Int] = [:]
Expand All @@ -148,7 +148,7 @@ struct WebPushManagerTests {
}

@Test func neverRetrievesDeprecatedKeys() async throws {
var configuration = VAPID.Configuration.mocked
var configuration = VAPID.Configuration.mockedConfiguration
try configuration.updateKeys(primaryKey: nil, keys: [.mockedKey1, .mockedKey2], deprecatedKeys: [.mockedKey3])
let manager = WebPushManager(vapidConfiguration: configuration)
for _ in 0..<100_000 {
Expand All @@ -163,7 +163,7 @@ struct WebPushManagerTests {
}

@Test func keyStatus() async throws {
var configuration = VAPID.Configuration.mocked
var configuration = VAPID.Configuration.mockedConfiguration
try configuration.updateKeys(primaryKey: .mockedKey1, keys: [.mockedKey2], deprecatedKeys: [.mockedKey3])
let manager = WebPushManager(vapidConfiguration: configuration)
#expect(manager.keyStatus(for: .mockedKeyID1) == .valid)
Expand Down
Loading