Skip to content

Commit

Permalink
bug: Should map metadata when converting from ResolutionDetails to Fl…
Browse files Browse the repository at this point in the history
…agEvaluationDetails

Signed-off-by: Benjamin Evenson <2031163+benjiro@users.noreply.github.com>
  • Loading branch information
benjiro committed Jul 25, 2024
1 parent 79def47 commit b68be64
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OpenFeature/Extension/ResolutionDetailsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class ResolutionDetailsExtensions
public static FlagEvaluationDetails<T> ToFlagEvaluationDetails<T>(this ResolutionDetails<T> details)
{
return new FlagEvaluationDetails<T>(details.FlagKey, details.Value, details.ErrorType, details.Reason,
details.Variant, details.ErrorMessage);
details.Variant, details.ErrorMessage, details.FlagMetadata);
}
}
}
19 changes: 19 additions & 0 deletions test/OpenFeature.Tests/OpenFeatureClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NSubstitute.ExceptionExtensions;
using OpenFeature.Constant;
using OpenFeature.Error;
using OpenFeature.Extension;
using OpenFeature.Model;
using OpenFeature.Tests.Internal;
using Xunit;
Expand Down Expand Up @@ -365,5 +366,23 @@ public void Should_Get_And_Set_Context()
client.SetContext(new EvaluationContextBuilder().Set(KEY, VAL).Build());
Assert.Equal(VAL, client.GetContext().GetValue(KEY).AsInteger);
}

[Fact]
public void ToFlagEvaluationDetails_Should_Convert_All_Properties()
{
var fixture = new Fixture();
var flagName = fixture.Create<string>();
var boolValue = fixture.Create<bool>();
var errorType = fixture.Create<ErrorType>();
var reason = fixture.Create<string>();
var variant = fixture.Create<string>();
var errorMessage = fixture.Create<string>();
var flagMetadata = fixture.Create<FlagMetadata>();

var expected = new ResolutionDetails<bool>(flagName, boolValue, errorType, reason, variant, errorMessage, flagMetadata);
var result = expected.ToFlagEvaluationDetails();

result.Should().BeEquivalentTo(expected);
}
}
}

0 comments on commit b68be64

Please sign in to comment.