From acf30beefb682362735cea3237cc1bd36ccdf923 Mon Sep 17 00:00:00 2001 From: Nicky Bondarenko Date: Tue, 16 Jul 2024 11:48:15 +0200 Subject: [PATCH] fix tests --- .../ConfidenceContextTests.swift | 20 +++++++++---------- .../EventSenderEngineTest.swift | 10 ++++++++-- .../FlagApplierWithRetriesTest.swift | 5 ++++- .../RemoteConfidenceClientTests.swift | 8 ++++---- .../RemoteResolveConfidenceClientTest.swift | 2 +- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Tests/ConfidenceTests/ConfidenceContextTests.swift b/Tests/ConfidenceTests/ConfidenceContextTests.swift index c41447cc..155c952d 100644 --- a/Tests/ConfidenceTests/ConfidenceContextTests.swift +++ b/Tests/ConfidenceTests/ConfidenceContextTests.swift @@ -6,7 +6,7 @@ final class ConfidenceContextTests: XCTestCase { func testWithContext() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -33,7 +33,7 @@ final class ConfidenceContextTests: XCTestCase { func testWithContextUpdateParent() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -65,7 +65,7 @@ final class ConfidenceContextTests: XCTestCase { func testUpdateLocalContext() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -92,7 +92,7 @@ final class ConfidenceContextTests: XCTestCase { func testUpdateLocalContextWithoutOverride() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -123,7 +123,7 @@ final class ConfidenceContextTests: XCTestCase { func testUpdateParentContextWithOverride() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -154,7 +154,7 @@ final class ConfidenceContextTests: XCTestCase { func testRemoveContextEntry() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -179,7 +179,7 @@ final class ConfidenceContextTests: XCTestCase { func testRemoveContextEntryFromParent() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -207,7 +207,7 @@ final class ConfidenceContextTests: XCTestCase { func testRemoveContextEntryFromParentAndChild() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -238,7 +238,7 @@ final class ConfidenceContextTests: XCTestCase { func testRemoveContextEntryFromParentAndChildThenUpdate() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -271,7 +271,7 @@ final class ConfidenceContextTests: XCTestCase { func testVisitorId() { let client = RemoteConfidenceResolveClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) diff --git a/Tests/ConfidenceTests/EventSenderEngineTest.swift b/Tests/ConfidenceTests/EventSenderEngineTest.swift index 7db33b67..6be4d436 100644 --- a/Tests/ConfidenceTests/EventSenderEngineTest.swift +++ b/Tests/ConfidenceTests/EventSenderEngineTest.swift @@ -110,7 +110,10 @@ final class EventSenderEngineTest: XCTestCase { func testRemoveEventsFromStorageOnBadRequest() throws { MockedClientURLProtocol.mockedOperation = .badRequest let badRequestUploader = RemoteConfidenceClient( - options: ConfidenceClientOptions(credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + options: ConfidenceClientOptions( + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), + timeoutIntervalForRequest: 10 + ), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -135,7 +138,10 @@ final class EventSenderEngineTest: XCTestCase { func testKeepEventsInStorageForRetry() throws { MockedClientURLProtocol.mockedOperation = .needRetryLater let retryLaterUploader = RemoteConfidenceClient( - options: ConfidenceClientOptions(credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + options: ConfidenceClientOptions( + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), + timeoutIntervalForRequest: 10 + ), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) diff --git a/Tests/ConfidenceTests/FlagApplierWithRetriesTest.swift b/Tests/ConfidenceTests/FlagApplierWithRetriesTest.swift index 5f781e5f..6ff64d34 100644 --- a/Tests/ConfidenceTests/FlagApplierWithRetriesTest.swift +++ b/Tests/ConfidenceTests/FlagApplierWithRetriesTest.swift @@ -8,7 +8,10 @@ import XCTest @available(macOS 13.0, iOS 16.0, *) class FlagApplierWithRetriesTest: XCTestCase { - private let options = ConfidenceClientOptions(credentials: .clientSecret(secret: "test")) + private let options = ConfidenceClientOptions( + credentials: .clientSecret(secret: "test"), + timeoutIntervalForRequest: 10 + ) private var storage = StorageMock() private var httpClient = HttpClientMock() private let metadata = ConfidenceMetadata(name: "test-provider-name", version: "0.0.0.") diff --git a/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift b/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift index 2d62d03b..bac83b1e 100644 --- a/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift +++ b/Tests/ConfidenceTests/RemoteConfidenceClientTests.swift @@ -12,7 +12,7 @@ class RemoteConfidenceClientTest: XCTestCase { func testUploadDoesntThrow() async throws { let client = RemoteConfidenceClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -29,7 +29,7 @@ class RemoteConfidenceClientTest: XCTestCase { func testUploadEmptyEventsDoesntThrow() async throws { let client = RemoteConfidenceClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -41,7 +41,7 @@ class RemoteConfidenceClientTest: XCTestCase { MockedClientURLProtocol.mockedOperation = .firstEventFails let client = RemoteConfidenceClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) @@ -59,7 +59,7 @@ class RemoteConfidenceClientTest: XCTestCase { MockedClientURLProtocol.mockedOperation = .malformedResponse let client = RemoteConfidenceClient( options: ConfidenceClientOptions( - credentials: ConfidenceClientCredentials.clientSecret(secret: "")), + credentials: ConfidenceClientCredentials.clientSecret(secret: ""), timeoutIntervalForRequest: 10), session: MockedClientURLProtocol.mockedSession(), metadata: ConfidenceMetadata(name: "", version: "")) diff --git a/Tests/ConfidenceTests/RemoteResolveConfidenceClientTest.swift b/Tests/ConfidenceTests/RemoteResolveConfidenceClientTest.swift index 16519b27..c2d310ae 100644 --- a/Tests/ConfidenceTests/RemoteResolveConfidenceClientTest.swift +++ b/Tests/ConfidenceTests/RemoteResolveConfidenceClientTest.swift @@ -26,7 +26,7 @@ class RemoteResolveConfidenceClientTest: XCTestCase { let session = MockedResolveClientURLProtocol.mockedSession(flags: flags) let client = RemoteConfidenceResolveClient( - options: .init(credentials: .clientSecret(secret: "test")), + options: .init(credentials: .clientSecret(secret: "test"), timeoutIntervalForRequest: 10), session: session, applyOnResolve: true, metadata: ConfidenceMetadata(name: "", version: "")