From dc702aee0f361a291c33d2e81a7915d4b9704262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihat=20Gu=CC=88ndu=CC=88z?= Date: Wed, 31 Jul 2024 16:52:46 +0200 Subject: [PATCH] Fix tests --- Tests/TelemetryClientTests/LogHandlerTests.swift | 11 +++++------ Tests/TelemetryClientTests/TelemetryClientTests.swift | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Tests/TelemetryClientTests/LogHandlerTests.swift b/Tests/TelemetryClientTests/LogHandlerTests.swift index 2a7f0bd..20412c2 100644 --- a/Tests/TelemetryClientTests/LogHandlerTests.swift +++ b/Tests/TelemetryClientTests/LogHandlerTests.swift @@ -2,15 +2,16 @@ import XCTest final class LogHandlerTests: XCTestCase { + var counter: Int = 0 + var lastLevel: LogHandler.LogLevel? + func testLogHandler_stdoutLogLevelDefined() { XCTAssertEqual(LogHandler.stdout(.error).logLevel, .error) } func testLogHandler_logLevelRespected() { - var counter = 0 - let handler = LogHandler(logLevel: .info) { _, _ in - counter += 1 + self.counter += 1 } XCTAssertEqual(counter, 0) @@ -23,10 +24,8 @@ final class LogHandlerTests: XCTestCase { } func testLogHandler_defaultLogLevel() { - var lastLevel: LogHandler.LogLevel? - let handler = LogHandler(logLevel: .debug) { level, _ in - lastLevel = level + self.lastLevel = level } handler.log(message: "") diff --git a/Tests/TelemetryClientTests/TelemetryClientTests.swift b/Tests/TelemetryClientTests/TelemetryClientTests.swift index 83e1f62..64226a3 100644 --- a/Tests/TelemetryClientTests/TelemetryClientTests.swift +++ b/Tests/TelemetryClientTests/TelemetryClientTests.swift @@ -61,7 +61,7 @@ final class TelemetryClientTests: XCTestCase { } } - let configuration = TelemetryManagerConfiguration(appID: UUID().uuidString) + var configuration = TelemetryManagerConfiguration(appID: UUID().uuidString) configuration.metadataEnrichers.append(BasicEnricher()) let signalManager = FakeSignalManager() @@ -81,7 +81,7 @@ final class TelemetryClientTests: XCTestCase { } } - let configuration = TelemetryManagerConfiguration(appID: UUID().uuidString) + var configuration = TelemetryManagerConfiguration(appID: UUID().uuidString) configuration.metadataEnrichers.append(BasicEnricher()) let signalManager = FakeSignalManager() @@ -111,7 +111,7 @@ final class TelemetryClientTests: XCTestCase { func testSendsSignals_withAnalyticsExplicitlyEnabled() { let YOUR_APP_ID = "44e0f59a-60a2-4d4a-bf27-1f96ccb4aaa3" - let configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) + var configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) configuration.analyticsDisabled = false let signalManager = FakeSignalManager() @@ -125,7 +125,7 @@ final class TelemetryClientTests: XCTestCase { func testDoesNotSendSignals_withAnalyticsExplicitlyDisabled() { let YOUR_APP_ID = "44e0f59a-60a2-4d4a-bf27-1f96ccb4aaa3" - let configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) + var configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) configuration.analyticsDisabled = true let signalManager = FakeSignalManager() @@ -141,7 +141,7 @@ final class TelemetryClientTests: XCTestCase { let YOUR_APP_ID = "44e0f59a-60a2-4d4a-bf27-1f96ccb4aaa3" - let configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) + var configuration = TelemetryManagerConfiguration(appID: YOUR_APP_ID) configuration.analyticsDisabled = false let signalManager = FakeSignalManager()