Skip to content

Commit

Permalink
Add a test for acquire/release
Browse files Browse the repository at this point in the history
  • Loading branch information
kovyrin committed Oct 16, 2024
1 parent 126fdf7 commit 7f911a6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ def test_acquire
assert(acquired)
end

def test_acquire_and_release_semaphore
resource = create_resource(:testing, tickets: 1)

assert_equal(1, resource.count)

begin
resource.acquire_semaphore

assert_equal(0, resource.count)
ensure
resource.release_semaphore

assert_equal(1, resource.count)
end
end

def test_acquire_return_val
resource = create_resource(:testing, tickets: 1)
val = resource.acquire { 1234 }
Expand Down

0 comments on commit 7f911a6

Please sign in to comment.