@@ -32,6 +32,22 @@ func doSDKContextTypeTests(t *ldtest.T) {
3232// a context object-- the current test harness architecture requires all test service commands to be directed
3333// at a client instance.
3434
35+ // CTXBLD 1.2.3: kind operation takes kind string and optional key, returns LDAttributesBuilder
36+ // CTXBLD 1.2.6: build operation returns LDContext
37+ // CTXBLD 1.2.7: one kind = individual context, more than one = multi-context
38+ // CTXBLD 1.4.1: dedicated name operation accepts string
39+ // CTXBLD 1.4.2: dedicated anonymous operation accepts boolean
40+ // CTXBLD 1.4.3: unset anonymous behaves as false
41+ // CTXBLD 1.5.1: generic attribute setter stores custom attributes
42+ // CTXBLD 1.5.3: null value removes custom attribute
43+ // CTXBLD 1.5.4: non-null value stores custom attribute
44+ // CTXBLD 1.6.4: add private attribute reference strings
45+ // CONTEXT 1.2.3.2: anonymous false treated as absent
46+ // CONTEXT 1.4.2: custom attribute value types (boolean, number, string, array, object)
47+ // CONTEXT 1.5.6: null attribute value treated as absent
48+ // CONTEXT 1.10.1.1: single-kind JSON includes kind and key
49+ // CONTEXT 1.10.2.1: multi-kind JSON includes kind:"multi"
50+ // CONTEXT 1.10.2.2: multi-kind sub-objects follow single-kind schema without kind property
3551func doSDKContextBuildTests (t * ldtest.T ) {
3652 dataSystem := NewSDKDataSystem (t , nil )
3753 client := NewSDKClient (t , dataSystem )
@@ -112,6 +128,8 @@ func doSDKContextBuildTests(t *ldtest.T) {
112128 })
113129}
114130
131+ // CONTEXT 1.12.4: SDK supports converting context to/from JSON
132+ // CONTEXT 1.12.5: SDK supports deserializing legacy JSON format
115133func doSDKContextConvertTests (t * ldtest.T ) {
116134 dataSystem := NewSDKDataSystem (t , nil )
117135 client := NewSDKClient (t , dataSystem )
@@ -123,6 +141,16 @@ func doSDKContextConvertTests(t *ldtest.T) {
123141 return fmt .Sprintf (`{"kind": "org", "key": "x"%s}` , extraProps )
124142 }
125143
144+ // CONTEXT 1.1.2: kind contains only allowed characters (ASCII alphanumerics, ., -, _)
145+ // CONTEXT 1.2.1.1: key present on every single-kind context
146+ // CONTEXT 1.2.2.1: name is a string if set
147+ // CONTEXT 1.2.3.1: anonymous is a boolean if set
148+ // CONTEXT 1.4.2: custom attribute value types
149+ // CONTEXT 1.10.1.1: single-kind includes kind and key as top-level properties
150+ // CONTEXT 1.10.1.2: _meta.privateAttributes format
151+ // CONTEXT 1.10.1.5: non-built-in top-level properties are custom attributes
152+ // CONTEXT 1.10.2.1: multi-kind includes kind:"multi"
153+ // CONTEXT 1.10.2.2: multi-kind sub-objects without kind property
126154 t .Run ("valid, no changes" , func (t * ldtest.T ) {
127155 singleKindProps := []string {
128156 `` ,
@@ -166,6 +194,8 @@ func doSDKContextConvertTests(t *ldtest.T) {
166194 }
167195 })
168196
197+ // CONTEXT 1.5.6: null attribute value treated as absent
198+ // CONTEXT 1.5.7: JSON null property treated as omitting property
169199 t .Run ("unnecessary properties are dropped" , func (t * ldtest.T ) {
170200 expected := json .RawMessage (basicInputPlusProps ("" ))
171201
@@ -186,6 +216,12 @@ func doSDKContextConvertTests(t *ldtest.T) {
186216 }
187217 })
188218
219+ // CONTEXT 1.10.3.1: no kind property means kind "user"
220+ // CONTEXT 1.10.3.2: legacy key and name treated same as regular context
221+ // CONTEXT 1.10.3.3: privateAttributeNames treated as _meta.privateAttributes
222+ // CONTEXT 1.10.3.4: legacy string attrs (firstName, lastName, email, country, ip, avatar)
223+ // CONTEXT 1.10.3.5: custom property treated as additional custom attributes
224+ // CONTEXT 1.12.5: SDK deserializes legacy JSON format
189225 t .Run ("old user to context" , func (t * ldtest.T ) {
190226 t .RequireCapability (servicedef .CapabilityUserType )
191227 type contextConversionParams struct {
@@ -235,6 +271,7 @@ func doSDKContextConvertTests(t *ldtest.T) {
235271 }
236272 })
237273
274+ // CTXBLD 1.2.7: multi-context with single kind normalizes to individual context
238275 t .Run ("multi-kind with only one kind becomes single-kind" , func (t * ldtest.T ) {
239276 singleKindJSON := `{"kind": "org", "key": "a", "name": "b"}`
240277 multiKindJSON := `{"kind": "multi", "org": {"key": "a", "name": "b"}}`
@@ -243,6 +280,14 @@ func doSDKContextConvertTests(t *ldtest.T) {
243280 m .In (t ).Assert (json .RawMessage (resp .Output ), m .JSONEqual (json .RawMessage (singleKindJSON )))
244281 })
245282
283+ // CONTEXT 1.1.1: kind must be non-empty string
284+ // CONTEXT 1.1.2: kind must contain only ASCII alphanumerics, ., -, _
285+ // CONTEXT 1.1.3: kind must not be "kind"
286+ // CONTEXT 1.13.1.1: invalid kind (empty, bad chars, or equals "kind")
287+ // CONTEXT 1.13.1.3: multi-kind with no contexts is invalid
288+ // CONTEXT 1.13.2.1: kind null or not a string is invalid
289+ // CONTEXT 1.13.2.2: single-kind type/schema validation errors
290+ // CONTEXT 1.13.4.1: deserialization must fail on invalid conditions
246291 t .Run ("invalid context" , func (t * ldtest.T ) {
247292 inputs := []string {
248293 `` ,
@@ -298,6 +343,7 @@ func doSDKContextConvertTests(t *ldtest.T) {
298343 })
299344 })
300345
346+ // CONTEXT 1.13.2.4: legacy format type/schema validation errors
301347 t .Run ("invalid old user" , func (t * ldtest.T ) {
302348 t .RequireCapability (servicedef .CapabilityUserType )
303349 inputs := make ([]string , 0 , 12 )
@@ -320,6 +366,8 @@ func doSDKContextConvertTests(t *ldtest.T) {
320366 })
321367}
322368
369+ // CTXBLD 1.8.4: equal contexts have same kinds, keys, names, anonymous, custom attrs, private attrs
370+ // CONTEXT 1.10.1.4: order of privateAttributes entries is not significant
323371func doSDKContextComparisonTests (t * ldtest.T ) {
324372 dataSystem := NewSDKDataSystem (t , nil )
325373 client := NewSDKClient (t , dataSystem )
0 commit comments