Skip to content

Commit d998e0b

Browse files
wip: add test cases for cmab services
1 parent 9c9b9b0 commit d998e0b

File tree

5 files changed

+664
-2
lines changed

5 files changed

+664
-2
lines changed

OptimizelySwiftSDK.xcodeproj/project.pbxproj

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,24 @@
21102110
98F28A502E02DD6D00A86546 /* CmabClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A402E02DD6D00A86546 /* CmabClient.swift */; };
21112111
98F28A522E02E81500A86546 /* CMABClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A512E02E81500A86546 /* CMABClientTests.swift */; };
21122112
98F28A532E02E81500A86546 /* CMABClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A512E02E81500A86546 /* CMABClientTests.swift */; };
2113+
98F28A562E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2114+
98F28A572E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2115+
98F28A582E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2116+
98F28A592E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2117+
98F28A5A2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2118+
98F28A5B2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2119+
98F28A5C2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2120+
98F28A5D2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2121+
98F28A5E2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2122+
98F28A5F2E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2123+
98F28A602E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2124+
98F28A612E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2125+
98F28A622E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2126+
98F28A632E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2127+
98F28A642E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2128+
98F28A652E0451CC00A86546 /* CmabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A552E0451CC00A86546 /* CmabService.swift */; };
2129+
98F28A672E05220300A86546 /* CmabServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A662E05220300A86546 /* CmabServiceTests.swift */; };
2130+
98F28A682E05220300A86546 /* CmabServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F28A662E05220300A86546 /* CmabServiceTests.swift */; };
21132131
BD1C3E8524E4399C0084B4DA /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B97DD93249D327F003DE606 /* SemanticVersion.swift */; };
21142132
BD64853C2491474500F30986 /* Optimizely.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E75167A22C520D400B2B157 /* Optimizely.h */; settings = {ATTRIBUTES = (Public, ); }; };
21152133
BD64853E2491474500F30986 /* Audience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E75169822C520D400B2B157 /* Audience.swift */; };
@@ -2565,6 +2583,8 @@
25652583
98F28A2D2E01968000A86546 /* CmabTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CmabTests.swift; sourceTree = "<group>"; };
25662584
98F28A402E02DD6D00A86546 /* CmabClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CmabClient.swift; sourceTree = "<group>"; };
25672585
98F28A512E02E81500A86546 /* CMABClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CMABClientTests.swift; sourceTree = "<group>"; };
2586+
98F28A552E0451CC00A86546 /* CmabService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CmabService.swift; sourceTree = "<group>"; };
2587+
98F28A662E05220300A86546 /* CmabServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CmabServiceTests.swift; sourceTree = "<group>"; };
25682588
BD6485812491474500F30986 /* Optimizely.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Optimizely.framework; sourceTree = BUILT_PRODUCTS_DIR; };
25692589
C78CAF572445AD8D009FE876 /* OptimizelyJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptimizelyJSON.swift; sourceTree = "<group>"; };
25702590
C78CAF652446DB91009FE876 /* OptimizelyClientTests_OptimizelyJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptimizelyClientTests_OptimizelyJSON.swift; sourceTree = "<group>"; };
@@ -3098,6 +3118,7 @@
30983118
8486180E286D0B8900B7F41B /* OdpManagerTests.swift */,
30993119
8486180D286D0B8900B7F41B /* OdpSegmentManagerTests.swift */,
31003120
98F28A512E02E81500A86546 /* CMABClientTests.swift */,
3121+
98F28A662E05220300A86546 /* CmabServiceTests.swift */,
31013122
8486180F286D0B8900B7F41B /* VuidManagerTests.swift */,
31023123
84861819286D188B00B7F41B /* OdpSegmentApiManagerTests.swift */,
31033124
8486181A286D188B00B7F41B /* OdpEventApiManagerTests.swift */,
@@ -3270,6 +3291,7 @@
32703291
isa = PBXGroup;
32713292
children = (
32723293
98F28A402E02DD6D00A86546 /* CmabClient.swift */,
3294+
98F28A552E0451CC00A86546 /* CmabService.swift */,
32733295
);
32743296
path = CMAB;
32753297
sourceTree = "<group>";
@@ -4343,6 +4365,7 @@
43434365
6E14CD752423F97600010234 /* OptimizelyConfig+ObjC.swift in Sources */,
43444366
6E14CD712423F96800010234 /* OptimizelyClient.swift in Sources */,
43454367
6E14CD842423F9A100010234 /* BatchEventBuilder.swift in Sources */,
4368+
98F28A5E2E0451CC00A86546 /* CmabService.swift in Sources */,
43464369
6E14CD6E2423F85E00010234 /* EventDispatcherTests_Batch.swift in Sources */,
43474370
6E14CDA92423F9C300010234 /* Utils.swift in Sources */,
43484371
98F28A472E02DD6D00A86546 /* CmabClient.swift in Sources */,
@@ -4416,6 +4439,7 @@
44164439
84E2E9782855875E001114AB /* OdpEventManager.swift in Sources */,
44174440
6E424CFA26324B620081004A /* DataStoreMemory.swift in Sources */,
44184441
6E424CFB26324B620081004A /* DataStoreUserDefaults.swift in Sources */,
4442+
98F28A652E0451CC00A86546 /* CmabService.swift in Sources */,
44194443
6E6522E4278E4F3800954EA1 /* OdpManager.swift in Sources */,
44204444
6E424CFC26324B620081004A /* DataStoreFile.swift in Sources */,
44214445
6E424CFD26324B620081004A /* DataStoreQueueStackImpl.swift in Sources */,
@@ -4574,6 +4598,7 @@
45744598
C78CAF592445AD8D009FE876 /* OptimizelyJSON.swift in Sources */,
45754599
848617C92863DC2700B7F41B /* OdpSegmentManager.swift in Sources */,
45764600
6E7518E922C520D400B2B157 /* ConditionHolder.swift in Sources */,
4601+
98F28A622E0451CC00A86546 /* CmabService.swift in Sources */,
45774602
6E75184122C520D400B2B157 /* Event.swift in Sources */,
45784603
6E7517C922C520D400B2B157 /* DefaultBucketer.swift in Sources */,
45794604
6E75181D22C520D400B2B157 /* BatchEventBuilder.swift in Sources */,
@@ -4667,6 +4692,7 @@
46674692
6E7516DE22C520D400B2B157 /* OPTUserProfileService.swift in Sources */,
46684693
6E75189022C520D400B2B157 /* Project.swift in Sources */,
46694694
6E75195C22C520D500B2B157 /* OPTBucketer.swift in Sources */,
4695+
98F28A572E0451CC00A86546 /* CmabService.swift in Sources */,
46704696
6E7518E422C520D400B2B157 /* ConditionLeaf.swift in Sources */,
46714697
6E7518F022C520D500B2B157 /* ConditionHolder.swift in Sources */,
46724698
98F28A442E02DD6D00A86546 /* CmabClient.swift in Sources */,
@@ -4830,6 +4856,7 @@
48304856
C78CAF7424482C86009FE876 /* OptimizelyClientTests_OptimizelyJSON.swift in Sources */,
48314857
6EC6DD3724ABF6990017D296 /* OptimizelyClient+Decide.swift in Sources */,
48324858
6E7516E622C520D400B2B157 /* OPTEventDispatcher.swift in Sources */,
4859+
98F28A612E0451CC00A86546 /* CmabService.swift in Sources */,
48334860
6EF8DE3724BF7D69008B9488 /* DecisionReasons.swift in Sources */,
48344861
6EC6DD4724ABF89B0017D296 /* OptimizelyUserContext.swift in Sources */,
48354862
6E7518F822C520D500B2B157 /* UserAttribute.swift in Sources */,
@@ -4904,6 +4931,7 @@
49044931
6E75188F22C520D400B2B157 /* Project.swift in Sources */,
49054932
6E75195B22C520D500B2B157 /* OPTBucketer.swift in Sources */,
49064933
6E7518E322C520D400B2B157 /* ConditionLeaf.swift in Sources */,
4934+
98F28A5D2E0451CC00A86546 /* CmabService.swift in Sources */,
49074935
6E7518EF22C520D400B2B157 /* ConditionHolder.swift in Sources */,
49084936
6E75182F22C520D400B2B157 /* BatchEvent.swift in Sources */,
49094937
6E75191F22C520D500B2B157 /* OPTNotificationCenter.swift in Sources */,
@@ -4959,6 +4987,7 @@
49594987
6E9B117422C5487100C22D81 /* DecisionServiceTests_Others.swift in Sources */,
49604988
6E9B116E22C5487100C22D81 /* LoggerTests.swift in Sources */,
49614989
84F6BADE27FD011B004BE62A /* OptimizelyUserContextTests_ODP_Decide.swift in Sources */,
4990+
98F28A5C2E0451CC00A86546 /* CmabService.swift in Sources */,
49624991
6E75180D22C520D400B2B157 /* DataStoreFile.swift in Sources */,
49634992
6E75178722C520D400B2B157 /* ArrayEventForDispatch+Extension.swift in Sources */,
49644993
6E75179F22C520D400B2B157 /* DataStoreQueueStackImpl+Extension.swift in Sources */,
@@ -5007,6 +5036,7 @@
50075036
6E75192D22C520D500B2B157 /* DataStoreQueueStack.swift in Sources */,
50085037
6E7516D322C520D400B2B157 /* OPTLogger.swift in Sources */,
50095038
6E75180122C520D400B2B157 /* DataStoreUserDefaults.swift in Sources */,
5039+
98F28A672E05220300A86546 /* CmabServiceTests.swift in Sources */,
50105040
98AC98472DB7B762001405DD /* BucketTests_HoldoutToVariation.swift in Sources */,
50115041
6E75175722C520D400B2B157 /* LogMessage.swift in Sources */,
50125042
98F28A242E01940500A86546 /* Cmab.swift in Sources */,
@@ -5153,6 +5183,7 @@
51535183
6E9B119622C5488300C22D81 /* AudienceTests.swift in Sources */,
51545184
6E7518B622C520D400B2B157 /* Group.swift in Sources */,
51555185
6E7516D422C520D400B2B157 /* OPTLogger.swift in Sources */,
5186+
98F28A602E0451CC00A86546 /* CmabService.swift in Sources */,
51565187
6E75183222C520D400B2B157 /* BatchEvent.swift in Sources */,
51575188
6E7518DA22C520D400B2B157 /* AttributeValue.swift in Sources */,
51585189
84640882281320F000CCF97D /* IntegrationTests.swift in Sources */,
@@ -5248,6 +5279,7 @@
52485279
6E9B115422C5486E00C22D81 /* LoggerTests.swift in Sources */,
52495280
6E7518DF22C520D400B2B157 /* ConditionLeaf.swift in Sources */,
52505281
6E75172D22C520D400B2B157 /* Constants.swift in Sources */,
5282+
98F28A5A2E0451CC00A86546 /* CmabService.swift in Sources */,
52515283
6E75172122C520D400B2B157 /* OptimizelyResult.swift in Sources */,
52525284
6E75186722C520D400B2B157 /* Rollout.swift in Sources */,
52535285
6E424C01263228FD0081004A /* AtomicDictionary.swift in Sources */,
@@ -5296,6 +5328,7 @@
52965328
6E75193322C520D500B2B157 /* OPTDataStore.swift in Sources */,
52975329
84861811286D0B8900B7F41B /* OdpSegmentManagerTests.swift in Sources */,
52985330
6E7517EF22C520D400B2B157 /* DataStoreMemory.swift in Sources */,
5331+
98F28A682E05220300A86546 /* CmabServiceTests.swift in Sources */,
52995332
6E75194B22C520D500B2B157 /* OPTDatafileHandler.swift in Sources */,
53005333
6E75195722C520D500B2B157 /* OPTBucketer.swift in Sources */,
53015334
98F28A2A2E01940500A86546 /* Cmab.swift in Sources */,
@@ -5437,6 +5470,7 @@
54375470
6E86CEA924FDC847005DAFED /* OptimizelyUserContext+ObjC.swift in Sources */,
54385471
6E9B118322C5488100C22D81 /* UserAttributeTests_Evaluate.swift in Sources */,
54395472
98F28A1D2E01940500A86546 /* Cmab.swift in Sources */,
5473+
98F28A582E0451CC00A86546 /* CmabService.swift in Sources */,
54405474
6E9B118E22C5488100C22D81 /* ProjectTests.swift in Sources */,
54415475
6E9B118022C5488100C22D81 /* AudienceTests.swift in Sources */,
54425476
6E7518B122C520D400B2B157 /* Group.swift in Sources */,
@@ -5563,6 +5597,7 @@
55635597
6E7517DA22C520D400B2B157 /* DefaultNotificationCenter.swift in Sources */,
55645598
6E7517E622C520D400B2B157 /* DefaultDecisionService.swift in Sources */,
55655599
984FE51F2CC8AA88004F6F41 /* UserProfileTracker.swift in Sources */,
5600+
98F28A5B2E0451CC00A86546 /* CmabService.swift in Sources */,
55665601
6E75171822C520D400B2B157 /* OptimizelyClient+ObjC.swift in Sources */,
55675602
98F28A452E02DD6D00A86546 /* CmabClient.swift in Sources */,
55685603
6E75174822C520D400B2B157 /* HandlerRegistryService.swift in Sources */,
@@ -5671,6 +5706,7 @@
56715706
6E7517DF22C520D400B2B157 /* DefaultNotificationCenter.swift in Sources */,
56725707
6E7517EB22C520D400B2B157 /* DefaultDecisionService.swift in Sources */,
56735708
984FE51D2CC8AA88004F6F41 /* UserProfileTracker.swift in Sources */,
5709+
98F28A562E0451CC00A86546 /* CmabService.swift in Sources */,
56745710
6E75171D22C520D400B2B157 /* OptimizelyClient+ObjC.swift in Sources */,
56755711
98F28A4A2E02DD6D00A86546 /* CmabClient.swift in Sources */,
56765712
6E75174D22C520D400B2B157 /* HandlerRegistryService.swift in Sources */,
@@ -5811,6 +5847,7 @@
58115847
C78CAF582445AD8D009FE876 /* OptimizelyJSON.swift in Sources */,
58125848
848617C82863DC2700B7F41B /* OdpSegmentManager.swift in Sources */,
58135849
6E75170622C520D400B2B157 /* OptimizelyClient.swift in Sources */,
5850+
98F28A642E0451CC00A86546 /* CmabService.swift in Sources */,
58145851
6E7518A022C520D400B2B157 /* FeatureFlag.swift in Sources */,
58155852
6E75174222C520D400B2B157 /* HandlerRegistryService.swift in Sources */,
58165853
6E75187022C520D400B2B157 /* Variation.swift in Sources */,
@@ -5904,6 +5941,7 @@
59045941
6E7517E222C520D400B2B157 /* DefaultDecisionService.swift in Sources */,
59055942
6E7516D822C520D400B2B157 /* OPTUserProfileService.swift in Sources */,
59065943
6E75188A22C520D400B2B157 /* Project.swift in Sources */,
5944+
98F28A5F2E0451CC00A86546 /* CmabService.swift in Sources */,
59075945
6E75195622C520D500B2B157 /* OPTBucketer.swift in Sources */,
59085946
6E7518DE22C520D400B2B157 /* ConditionLeaf.swift in Sources */,
59095947
98F28A4B2E02DD6D00A86546 /* CmabClient.swift in Sources */,
@@ -6017,6 +6055,7 @@
60176055
75C71A2E25E454460084187E /* Project.swift in Sources */,
60186056
75C71A2F25E454460084187E /* Experiment.swift in Sources */,
60196057
75C71A3025E454460084187E /* FeatureFlag.swift in Sources */,
6058+
98F28A592E0451CC00A86546 /* CmabService.swift in Sources */,
60206059
75C71A3125E454460084187E /* Group.swift in Sources */,
60216060
75C71A3225E454460084187E /* Variable.swift in Sources */,
60226061
848617DD2863E21200B7F41B /* OdpSegmentApiManager.swift in Sources */,
@@ -6119,6 +6158,7 @@
61196158
BD6485662491474500F30986 /* OptimizelyJSON.swift in Sources */,
61206159
848617CA2863DC2700B7F41B /* OdpSegmentManager.swift in Sources */,
61216160
BD6485672491474500F30986 /* OptimizelyClient.swift in Sources */,
6161+
98F28A632E0451CC00A86546 /* CmabService.swift in Sources */,
61226162
BD6485682491474500F30986 /* FeatureFlag.swift in Sources */,
61236163
BD6485692491474500F30986 /* HandlerRegistryService.swift in Sources */,
61246164
BD64856A2491474500F30986 /* Variation.swift in Sources */,

Sources/CMAB/CmabClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protocol CmabClient {
4242
func fetchDecision(
4343
ruleId: String,
4444
userId: String,
45-
attributes: [String: Any],
45+
attributes: [String: Any?],
4646
cmabUUID: String,
4747
completion: @escaping (Result<String, Error>) -> Void
4848
)
@@ -67,7 +67,7 @@ class DefaultCmabClient: CmabClient {
6767
func fetchDecision(
6868
ruleId: String,
6969
userId: String,
70-
attributes: [String: Any],
70+
attributes: [String: Any?],
7171
cmabUUID: String,
7272
completion: @escaping (Result<String, Error>) -> Void
7373
) {

0 commit comments

Comments
 (0)