Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Nov 7, 2024
1 parent f4a9ec7 commit b3df7fc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions spec/graphql/dataloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1086,13 +1086,13 @@ def self.included(child_class)
end

describe "fiber_limit" do
def assert_last_max_fiber_count(expected_last_max_fiber_count)
if schema.dataloader_class == GraphQL::Dataloader::AsyncDataloader && FiberCounting.last_max_fiber_count == (expected_last_max_fiber_count + 1)
def assert_last_max_fiber_count(expected_last_max_fiber_count, message = nil)
if FiberCounting.last_max_fiber_count == (expected_last_max_fiber_count + 1)
# TODO why does this happen sometimes?
warn "AsyncDataloader had +1 last_max_fiber_count"
assert_equal (expected_last_max_fiber_count + 1), FiberCounting.last_max_fiber_count
assert_equal (expected_last_max_fiber_count + 1), FiberCounting.last_max_fiber_count, message
else
assert_equal expected_last_max_fiber_count, FiberCounting.last_max_fiber_count
assert_equal expected_last_max_fiber_count, FiberCounting.last_max_fiber_count, message
end
end

Expand Down Expand Up @@ -1122,17 +1122,17 @@ def assert_last_max_fiber_count(expected_last_max_fiber_count)
res = schema.execute(query_str, context: { dataloader: fiber_counting_dataloader_class.new })
assert_nil res.context.dataloader.fiber_limit
assert_equal 12, FiberCounting.last_spawn_fiber_count
assert_last_max_fiber_count(9)
assert_last_max_fiber_count(9, "No limit works as expected")

res = schema.execute(query_str, context: { dataloader: fiber_counting_dataloader_class.new(fiber_limit: 4) })
assert_equal 4, res.context.dataloader.fiber_limit
assert_equal 14, FiberCounting.last_spawn_fiber_count
assert_last_max_fiber_count(4)
assert_last_max_fiber_count(4, "Limit of 4 works as expected")

res = schema.execute(query_str, context: { dataloader: fiber_counting_dataloader_class.new(fiber_limit: 6) })
assert_equal 6, res.context.dataloader.fiber_limit
assert_equal 10, FiberCounting.last_spawn_fiber_count
assert_last_max_fiber_count(6)
assert_last_max_fiber_count(6, "Limit of 6 works as expected")
end

it "accepts a default fiber_limit config" do
Expand Down

0 comments on commit b3df7fc

Please sign in to comment.