From bcc5574b6e1b82cec393c40469c8462d0d573284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pantale=C3=A3o=20Gon=C3=A7alves?= Date: Thu, 7 Dec 2023 08:59:24 -0300 Subject: [PATCH] Fix flaky test testComplicationsWithPreRendered (#2472) --- .../WebhookResponseUpdateComplications.test.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Tests/Shared/Webhook/WebhookResponseUpdateComplications.test.swift b/Tests/Shared/Webhook/WebhookResponseUpdateComplications.test.swift index 1ca95c5e2..a3aea777d 100644 --- a/Tests/Shared/Webhook/WebhookResponseUpdateComplications.test.swift +++ b/Tests/Shared/Webhook/WebhookResponseUpdateComplications.test.swift @@ -8,7 +8,6 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase { private var api: FakeHomeAssistantAPI! private var webhookManager: FakeWebhookManager! private var realm: Realm! - private var handler: WebhookResponseUpdateComplications? override func setUpWithError() throws { try super.setUpWithError() @@ -25,6 +24,12 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase { FakeWatchComplication.rawRenderedUpdates = [:] } + override func tearDown() { + api = nil + webhookManager = nil + realm = nil + } + func testNoComplicationGivesNoRequest() { XCTAssertNil(WebhookResponseUpdateComplications.request(for: .init())) } @@ -127,8 +132,8 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase { realm.add(complications) } - handler = WebhookResponseUpdateComplications(api: api) - handler?.watchComplicationClass = FakeWatchComplication.self + var handler = WebhookResponseUpdateComplications(api: api) + handler.watchComplicationClass = FakeWatchComplication.self let request = WebhookResponseUpdateComplications.request(for: Set(complications))! let result: [String: Any] = [ @@ -137,8 +142,6 @@ class WebhookResponseUpdateComplicationsTests: XCTestCase { "c3|fwc3k1": 3, ] - guard let handler = handler else { return } - let expectation = self.expectation(description: "result") handler.handle(request: .value(request), result: .value(result)).done { handlerResult in XCTAssertNil(handlerResult.notification)