Skip to content

Commit

Permalink
Solved issue with wrong targeting_key transformation, which resulted …
Browse files Browse the repository at this point in the history
…in errors.
  • Loading branch information
augustinasrce committed Aug 28, 2024
1 parent cb33998 commit 83b2c97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def prepare_evaluation_context(evaluation_context)
return nil unless evaluation_context

fields = evaluation_context.fields
fields["targetingKey"] = fields.delete(:targeting_key)
fields["targetingKey"] = fields.delete("targeting_key")
Google::Protobuf::Struct.from_hash(fields)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,26 @@
)
end
end

context "EvaluationContext transformation" do
subject { client.send(:prepare_evaluation_context, evaluation_context) }
let(:evaluation_context) { OpenFeature::SDK::EvaluationContext.new(**fields) }

context "No context" do
let(:evaluation_context) { nil }

it do
expect(subject).to be nil
end
end

context "targeting_key transformation to targetingKey" do
let(:fields) { {targeting_key: "example"} }
let(:expected) { Google::Protobuf::Struct.from_hash({targetingKey: "example"}.transform_keys(&:to_s)) }

it do
expect(subject).to eq(expected)
end
end
end
end

0 comments on commit 83b2c97

Please sign in to comment.