Skip to content

Commit

Permalink
Add test for cache delete
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikspang committed Oct 17, 2024
1 parent 429033d commit 89b07c3
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@
expect(cache_transaction[:spans][1][:data]['cache.key']).to eq(["my_cache_key_non_existing"])
expect(cache_transaction[:spans][1][:data]['cache.hit']).to eq(false)
end

it "tracks cache delete" do
Rails.cache.write("my_cache_key", "my_cache_value")
transaction = Sentry::Transaction.new(sampled: true, hub: Sentry.get_current_hub)
Sentry.get_current_scope.set_span(transaction)
Rails.cache.delete("my_cache_key")

transaction.finish
expect(transport.events.count).to eq(1)
cache_transaction = transport.events.first.to_hash
expect(cache_transaction[:type]).to eq("transaction")
expect(cache_transaction[:spans].count).to eq(1)
expect(cache_transaction[:spans][0][:op]).to eq("cache.remove")
expect(cache_transaction[:spans][0][:origin]).to eq("auto.cache.rails")
expect(cache_transaction[:spans][0][:data]['cache.key']).to eq(["my_cache_key"])
end
end

context "when transaction is not sampled" do
Expand Down

0 comments on commit 89b07c3

Please sign in to comment.