@@ -286,6 +286,45 @@ void main() {
286286 });
287287 });
288288
289+ group ('given an invalid context' , () {
290+ test ('start returns false with invalid context' , () async {
291+ final invalidClient = LDCommonClient (
292+ TestConfig ('' , AutoEnvAttributes .disabled, offline: true ),
293+ CommonPlatform (),
294+ LDContextBuilder ()
295+ .kind ('invalid#kind' , '' ) // invalid kind and invalid key
296+ .build (),
297+ DiagnosticSdkData (name: '' , version: '' ));
298+
299+ expect (await invalidClient.start (), false );
300+ });
301+
302+ test ('identify returns IdentifyError with invalid context' , () async {
303+ final invalidClient = LDCommonClient (
304+ TestConfig ('' , AutoEnvAttributes .disabled, offline: true ),
305+ CommonPlatform (),
306+ LDContextBuilder ()
307+ .kind ('user' , 'bob' )
308+ .build (), // Valid initial context
309+ DiagnosticSdkData (name: '' , version: '' ));
310+
311+ await invalidClient.start ();
312+
313+ final invalidContext = LDContextBuilder ()
314+ .kind ('invalid#kind' , '' ) // invalid kind and invalid key
315+ .build ();
316+
317+ expect (
318+ await invalidClient.identify (invalidContext), isA <IdentifyError >());
319+
320+ // check subsequent identify with valid context is accepted
321+ final validContext = LDContextBuilder ().kind ('user' , 'alice' ).build ();
322+
323+ final identifyResult = await invalidClient.identify (validContext);
324+ expect (identifyResult, isA <IdentifyComplete >());
325+ });
326+ });
327+
289328 group ('given mock flag data with prerequisites' , () {
290329 late LDCommonClient client;
291330 late MockPersistence mockPersistence;
0 commit comments