Skip to content

Commit

Permalink
Fix crash in Auth when running unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishpatil-g committed Sep 17, 2024
1 parent 4f74b52 commit 70a398e
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions Tests/Unit/InstanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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")
}
Expand All @@ -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)
Expand Down

0 comments on commit 70a398e

Please sign in to comment.