Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def evaluate(flag_key:, default_value:, allowed_classes:, evaluation_context: ni
)
end

if parsed_response.reason == SDK::Provider::Reason::DISABLED
return SDK::Provider::ResolutionDetails.new(
value: default_value,
reason: SDK::Provider::Reason::DISABLED
)
end

unless allowed_classes.include?(parsed_response.value.class)
return SDK::Provider::ResolutionDetails.new(
value: default_value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,36 @@
)
expect(got).to eql(want)
end

it "should return the default value if the reason is DISABLED" do
test_name = RSpec.current_example.description
stub_request(:post, "http://localhost:1031/ofrep/v1/evaluate/flags/boolean_flag")
.to_return(status: 200, body:
{
key: "boolean_flag",
metadata: {"website" => "https://gofeatureflag.org"},
value: true,
reason: "DISABLED",
variant: "variantA"
}.to_json)
OpenFeature::SDK.configure do |config|
config.set_provider(goff_provider, domain: test_name)
end
client = OpenFeature::SDK.build_client(domain: test_name)
got = client.fetch_boolean_details(
flag_key: "boolean_flag",
default_value: false,
evaluation_context: OpenFeature::SDK::EvaluationContext.new(targeting_key: "1234")
)
want = OpenFeature::SDK::EvaluationDetails.new(
flag_key: "boolean_flag",
resolution_details: OpenFeature::SDK::Provider::ResolutionDetails.new(
value: false,
reason: OpenFeature::SDK::Provider::Reason::DISABLED
)
)
expect(got).to eql(want)
end
end

context "#fetch_string_value with openfeature" do
Expand Down