Skip to content

Commit

Permalink
Add spec ensuring instrumentation applied only once
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jul 1, 2024
1 parent 4d03d40 commit d47a8f3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/unit/relation/instrument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,30 @@ def instrument(*args, &block)
expect(notifications.logs)
.to include([:sql, {name: :sqlite, query: "SELECT count(*) AS 'count' FROM `users` LIMIT 1"}])
end

context "two containers with shared gateway" do
let(:conf_alt) { TestConfiguration.new(:sql, conn) }

let(:container_alt) { ROM.setup(conf_alt) }

before do
conf_alt.plugin(:sql, relations: :instrumentation)

conf_alt.relation(:users) do
schema(infer: true)
end

container_alt
end

it "instruments relation materialization but does it once" do
relation.to_a

entries = notifications.logs.count do |log|
log.eql?([:sql, {name: :sqlite, query: relation.dataset.sql}])
end

expect(entries).to be(1)
end
end
end

0 comments on commit d47a8f3

Please sign in to comment.