From 654cd9a4a7870d23d11fd62320217da5690ee88a Mon Sep 17 00:00:00 2001 From: xiaoweii Date: Fri, 19 Jul 2024 11:33:39 +0800 Subject: [PATCH] feat: add test case for verify modify attributes in multiple thread --- Tests/ClickstreamTests/IntegrationTest.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/ClickstreamTests/IntegrationTest.swift b/Tests/ClickstreamTests/IntegrationTest.swift index 22c3e87..9143921 100644 --- a/Tests/ClickstreamTests/IntegrationTest.swift +++ b/Tests/ClickstreamTests/IntegrationTest.swift @@ -333,6 +333,26 @@ class IntegrationTest: XCTestCase { XCTAssertEqual(1, eventCount) } + func testModifyUserAttributesInMulitThread() throws { + for number in 1 ... 100 { + Task { + ClickstreamAnalytics.addUserAttributes([ + "_user_age": 21, + "isFirstOpen": true, + "score": 85.2, + "_user_name": "name\(number)" + ]) + } + Task { + ClickstreamAnalytics.setUserId("userId\(number)") + } + Task { + ClickstreamAnalytics.recordEvent("testEvent\(number)") + } + } + Thread.sleep(forTimeInterval: 1) + } + // MARK: - Objc test func testRecordEventForObjc() throws {