From 70a398ef2408810cdb834ef4b9de86dab24ca76f Mon Sep 17 00:00:00 2001 From: Aashish Patil Date: Tue, 17 Sep 2024 14:47:27 -0700 Subject: [PATCH 1/2] Fix crash in Auth when running unit tests --- Tests/Unit/InstanceTests.swift | 38 +++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Tests/Unit/InstanceTests.swift b/Tests/Unit/InstanceTests.swift index ad6bb23..9a490c6 100644 --- a/Tests/Unit/InstanceTests.swift +++ b/Tests/Unit/InstanceTests.swift @@ -19,8 +19,26 @@ import XCTest @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) class InstanceTests: XCTestCase { - var defaultApp: FirebaseApp? - var appTwo: FirebaseApp? + static var defaultApp: FirebaseApp? + static var appTwo: FirebaseApp? + + static var options: FirebaseOptions = { + let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000", + gcmSenderID: "00000000000000000-00000000000-000000000") + options.projectID = "fdc-test" + options.apiKey = "testDummyApiKey" + return options + }() + + static var optionsTwo: FirebaseOptions = { + let optionsTwo = FirebaseOptions( + googleAppID: "0:0000000000001:ios:0000000000000001", + gcmSenderID: "00000000000000000-00000000000-000000001" + ) + optionsTwo.projectID = "fdc-test" + optionsTwo.apiKey = "testDummyApiKey2" + return optionsTwo + }() var fakeConnectorConfigOne = ConnectorConfig( serviceId: "dataconnect", @@ -33,18 +51,11 @@ class InstanceTests: XCTestCase { connector: "blogs" ) - override func setUp() { - let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000", - gcmSenderID: "00000000000000000-00000000000-000000000") - options.projectID = "fdc-test" + override class func setUp() { FirebaseApp.configure(options: options) defaultApp = FirebaseApp.app() - let optionsTwo = FirebaseOptions( - googleAppID: "0:0000000000001:ios:0000000000000001", - gcmSenderID: "00000000000000000-00000000000-000000001" - ) - optionsTwo.projectID = "fdc-test" + FirebaseApp.configure(name: "app-two", options: optionsTwo) appTwo = FirebaseApp.app(name: "app-two") } @@ -62,7 +73,10 @@ class InstanceTests: XCTestCase { // same connector config, different apps, instances should be different func testDifferentInstanceDifferentApps() throws { let dcOne = DataConnect.dataConnect(connectorConfig: fakeConnectorConfigOne) - let dcTwo = DataConnect.dataConnect(app: appTwo, connectorConfig: fakeConnectorConfigTwo) + let dcTwo = DataConnect.dataConnect( + app: InstanceTests.appTwo, + connectorConfig: fakeConnectorConfigTwo + ) let isDifferent = dcOne !== dcTwo XCTAssertTrue(isDifferent) From db52efc62940fbffbd8de5291501df97a6b078cf Mon Sep 17 00:00:00 2001 From: Aashish Patil Date: Tue, 17 Sep 2024 15:20:34 -0700 Subject: [PATCH 2/2] Formatting fixes --- .gitignore | 7 +++++++ Tests/Unit/InstanceTests.swift | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5d09258..5fc318d 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,10 @@ default.profraw *.tfstate *.tfstate.* *.xcuserstate + + +#firebase-ios-sdk clone +firebase-ios-sdk/ + +#scripts link +scripts diff --git a/Tests/Unit/InstanceTests.swift b/Tests/Unit/InstanceTests.swift index 9a490c6..a86c782 100644 --- a/Tests/Unit/InstanceTests.swift +++ b/Tests/Unit/InstanceTests.swift @@ -55,7 +55,6 @@ class InstanceTests: XCTestCase { FirebaseApp.configure(options: options) defaultApp = FirebaseApp.app() - FirebaseApp.configure(name: "app-two", options: optionsTwo) appTwo = FirebaseApp.app(name: "app-two") }