Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in Auth when running unit tests #4

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ scripts

#xcodebuild log
xcodebuild.log

37 changes: 25 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,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")
}
Expand All @@ -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)
Expand Down