@@ -51,7 +51,8 @@ private static HttpMessageHandler InitMock()
5151 "{\" trackEvents\" :true,\" variationType\" :\" True\" ,\" failed\" :false,\" version\" :\" \" ,\" reason\" :\" TARGETING_MATCH\" ,\" errorCode\" :\" \" ,\" value\" :\" CC0000\" }" ) ;
5252 mockHttp . When ( $ "{ prefixEval } unknown_reason{ suffixEval } ") . Respond ( mediaType ,
5353 "{\" trackEvents\" :true,\" variationType\" :\" True\" ,\" failed\" :false,\" version\" :\" \" ,\" reason\" :\" CUSTOM_REASON\" ,\" errorCode\" :\" \" ,\" value\" :true}" ) ;
54-
54+ mockHttp . When ( $ "{ prefixEval } does_not_exists{ suffixEval } ") . Respond ( mediaType ,
55+ "{\" trackEvents\" :true,\" variationType\" :\" defaultSdk\" ,\" failed\" :true,\" version\" :\" \" ,\" reason\" :\" ERROR\" ,\" errorCode\" :\" FLAG_NOT_FOUND\" ,\" value\" :\" \" }" ) ;
5556 return mockHttp ;
5657 }
5758
@@ -500,4 +501,23 @@ private void should_resolve_a_valid_value_flag_with_a_list()
500501 Assert . Equal ( Reason . TargetingMatch , res . Result . Reason ) ;
501502 Assert . Equal ( "True" , res . Result . Variant ) ;
502503 }
504+
505+ [ Fact ]
506+ private void should_use_object_default_value_if_flag_not_found ( )
507+ {
508+ var g = new GoFeatureFlagProvider ( new GoFeatureFlagProviderOptions
509+ {
510+ Endpoint = baseUrl ,
511+ HttpMessageHandler = _mockHttp ,
512+ Timeout = new TimeSpan ( 1000 * TimeSpan . TicksPerMillisecond )
513+ } ) ;
514+ Api . Instance . SetProvider ( g ) ;
515+ var client = Api . Instance . GetClient ( "test-client" ) ;
516+ var res = client . GetObjectDetails ( "does_not_exists" , new Value ( "default" ) , _defaultEvaluationCtx ) ;
517+ Assert . NotNull ( res . Result ) ;
518+ Assert . Equal ( new Value ( "default" ) . AsString , res . Result . Value . AsString ) ;
519+ Assert . Equal ( Reason . Error , res . Result . Reason ) ;
520+ Assert . Equal ( ErrorType . FlagNotFound , res . Result . ErrorType ) ;
521+ Assert . Equal ( "flag does_not_exists was not found in your configuration" , res . Result . ErrorMessage ) ;
522+ }
503523}
0 commit comments