@@ -866,3 +866,46 @@ func TestClientProviderLock(t *testing.T) {
866866 t .Error (err )
867867 }
868868}
869+
870+ func TestObjectEvaluationShouldSupportNilValue (t * testing.T ) {
871+ defer t .Cleanup (initSingleton )
872+ ctrl := gomock .NewController (t )
873+
874+ variant := "variant1"
875+ reason := TargetingMatchReason
876+ var value interface {} = nil
877+
878+ mockProvider := NewMockFeatureProvider (ctrl )
879+ mockProvider .EXPECT ().Metadata ().AnyTimes ()
880+ mockProvider .EXPECT ().Hooks ().AnyTimes ()
881+ SetProvider (mockProvider )
882+ mockProvider .EXPECT ().ObjectEvaluation (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).
883+ Return (InterfaceResolutionDetail {
884+ Value : value ,
885+ ProviderResolutionDetail : ProviderResolutionDetail {
886+ Variant : variant ,
887+ Reason : reason ,
888+ },
889+ })
890+
891+ client := NewClient ("test" )
892+ evDetails , err := client .ObjectValueDetails (context .Background (), "foo" , nil , EvaluationContext {})
893+ if err != nil {
894+ t .Errorf ("should not return an error: %s" , err .Error ())
895+ }
896+ if evDetails .Value != value {
897+ t .Errorf ("unexpected value returned (expected: %s, value: %s)" , value , evDetails .Value )
898+ }
899+ if evDetails .Variant != variant {
900+ t .Errorf ("unexpected variant returned (expected: %s, value: %s)" , variant , evDetails .Variant )
901+ }
902+ if evDetails .Reason != reason {
903+ t .Errorf ("unexpected reason returned (expected: %s, value: %s)" , reason , evDetails .Reason )
904+ }
905+ if evDetails .ErrorMessage != "" {
906+ t .Error ("not supposed to have an error message" )
907+ }
908+ if evDetails .ErrorCode != "" {
909+ t .Error ("not supposed to have an error code" )
910+ }
911+ }
0 commit comments