Skip to content

Commit

Permalink
Assert correct elements are removed from hashes larger than limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptolts committed Oct 27, 2023
1 parent afc7bc5 commit 746f3f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/test/opentelemetry/trace/tracestate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(h)
_(tracestate.to_h).must_equal('the-good-key' => ' the-good-value', '0x_the-vendor/key@my*v3nd0r' => 'another-great-value')
end
it 'will not exceed 32 members' do
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(33.times.collect { |n| [n.to_s, n.to_s] }.to_h)
_(tracestate.to_h.size).must_be :<=, 32
it 'will not exceed 32 members and drops excess from the beginning' do
input_hash = 33.times.collect { [('a'..'z').to_a.sample(5).join, ('a'..'z').to_a.sample(5).join] }.to_h
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(input_hash)
output_hash = tracestate.to_h
_(output_hash.size).must_be :<=, 32
_(output_hash).must_equal(input_hash.drop(1).to_h)
end
end

Expand Down

0 comments on commit 746f3f2

Please sign in to comment.