Skip to content

Commit e5807c1

Browse files
committed
test tweaks
1 parent fe77c3f commit e5807c1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

MixpanelDemo/MixpanelDemoTests/MixpanelBaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class MixpanelBaseTests: XCTestCase, MixpanelDelegate {
5858
return ""
5959
}
6060

61-
guard let urlUnwrapped = url?.appendingPathComponent("\(token ?? apiToken)_MPDB.sqlite").path else {
61+
guard let urlUnwrapped = url?.appendingPathComponent("\(apiToken)_MPDB.sqlite").path else {
6262
return ""
6363
}
6464
return urlUnwrapped

MixpanelDemo/MixpanelDemoTests/MixpanelDemoTests.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,21 @@ class MixpanelDemoTests: MixpanelBaseTests {
364364
let testMixpanel = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60)
365365
let testMixpanel2 = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60)
366366
XCTAssertNotEqual(testMixpanel.distinctId, testMixpanel2.distinctId, "by default, distinctId should not be unique to the device")
367-
367+
368368
let testMixpanel3 = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60, useUniqueDistinctId: false)
369369
let testMixpanel4 = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60, useUniqueDistinctId: false)
370370
XCTAssertNotEqual(testMixpanel3.distinctId, testMixpanel4.distinctId, "distinctId should not be unique to the device if useUniqueDistinctId is set to false")
371-
371+
372372
let testMixpanel5 = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60, useUniqueDistinctId: true)
373373
let testMixpanel6 = Mixpanel.initialize(token: randomId(), trackAutomaticEvents: true, flushInterval: 60, useUniqueDistinctId: true)
374374
XCTAssertEqual(testMixpanel5.distinctId, testMixpanel6.distinctId, "distinctId should be unique to the device if useUniqueDistinctId is set to true")
375+
376+
removeDBfile(testMixpanel.apiToken)
377+
removeDBfile(testMixpanel2.apiToken)
378+
removeDBfile(testMixpanel3.apiToken)
379+
removeDBfile(testMixpanel4.apiToken)
380+
removeDBfile(testMixpanel5.apiToken)
381+
removeDBfile(testMixpanel6.apiToken)
375382
}
376383

377384
func testHadPersistedDistinctId() {
@@ -554,6 +561,7 @@ class MixpanelDemoTests: MixpanelBaseTests {
554561
let e = eventQueue(token: testMixpanel.apiToken).last!
555562
let p = e["properties"] as! InternalProperties
556563
XCTAssertNotNil(p["mp_lib"], "flutter")
564+
removeDBfile(testMixpanel.apiToken)
557565
}
558566

559567
func testInvalidPropertiesTrack() {
@@ -933,6 +941,7 @@ class MixpanelDemoTests: MixpanelBaseTests {
933941
testMixpanel = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60)
934942
testMixpanel2 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60)
935943
XCTAssertTrue(testMixpanel === testMixpanel2, "instance with same token should be reused and no sqlite db locked error should be populated")
944+
removeDBfile(testToken)
936945
}
937946

938947
func testMultipleInstancesWithSameTokenButDifferentInstanceNameShouldNotCrash() {
@@ -957,6 +966,7 @@ class MixpanelDemoTests: MixpanelBaseTests {
957966

958967
func testMultipleInstancesWithSameTokenButDifferentInstanceName() {
959968
let testToken = randomId()
969+
removeDBfile(testToken)
960970
let instance1 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: "instance1")
961971
let instance2 = Mixpanel.initialize(token: testToken, trackAutomaticEvents: true, flushInterval: 60, instanceName: "instance2")
962972

@@ -974,7 +984,6 @@ class MixpanelDemoTests: MixpanelBaseTests {
974984

975985
instance1.people.set(property: "p1", to: "a")
976986
waitForTrackingQueue(instance1)
977-
978987
let peopleQueue_value = peopleQueue(token: "instance1")
979988
let setValue = peopleQueue_value.last!["$set"] as! InternalProperties
980989
XCTAssertEqual(setValue["p1"] as? String, "a", "custom people property not queued")

0 commit comments

Comments
 (0)