@@ -427,6 +427,9 @@ class OptimizelyUserContextTests_ForcedDecisions: XCTestCase {
427
427
428
428
func testClone( ) {
429
429
let user = optimizely. createUserContext ( userId: kUserId, attributes: [ " country " : " us " ] )
430
+
431
+ // clone with empty ForcedDecisions
432
+
430
433
guard let user2 = user. clone else {
431
434
XCTFail ( )
432
435
return
@@ -435,6 +438,8 @@ class OptimizelyUserContextTests_ForcedDecisions: XCTestCase {
435
438
XCTAssertEqual ( user2. attributes [ " country " ] as? String , " us " )
436
439
XCTAssertNil ( user2. forcedDecisions)
437
440
441
+ // clone with non-empty ForcedDecisions
442
+
438
443
_ = user. setForcedDecision ( flagKey: " a " , variationKey: " b " )
439
444
_ = user. setForcedDecision ( flagKey: " a " , ruleKey: " c " , variationKey: " d " )
440
445
@@ -448,6 +453,12 @@ class OptimizelyUserContextTests_ForcedDecisions: XCTestCase {
448
453
XCTAssertEqual ( user3. getForcedDecision ( flagKey: " a " ) , " b " )
449
454
XCTAssertEqual ( user3. getForcedDecision ( flagKey: " a " , ruleKey: " c " ) , " d " )
450
455
XCTAssertNil ( user3. getForcedDecision ( flagKey: " x " ) )
456
+
457
+ // clone should have a separate copy for FocedDecisions
458
+
459
+ _ = user. setForcedDecision ( flagKey: " a " , ruleKey: " new-rk " , variationKey: " new-vk " )
460
+ XCTAssertEqual ( user. getForcedDecision ( flagKey: " a " , ruleKey: " new-rk " ) , " new-vk " )
461
+ XCTAssertNil ( user3. getForcedDecision ( flagKey: " a " , ruleKey: " new-rk " ) )
451
462
}
452
463
453
464
}
0 commit comments