diff --git a/.gitignore b/.gitignore index 9b32755..95735c7 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,4 @@ scripts #xcodebuild log xcodebuild.log + diff --git a/Tests/Unit/InstanceTests.swift b/Tests/Unit/InstanceTests.swift index ad6bb23..a86c782 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,10 @@ 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 +72,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)