mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
31 lines
595 B
Crystal
31 lines
595 B
Crystal
require "./spec_helper"
|
|
|
|
class ADisposable
|
|
include DB::Disposable
|
|
@raise = false
|
|
|
|
property raise
|
|
|
|
protected def do_close
|
|
raise "Unable to close" if @raise
|
|
end
|
|
end
|
|
|
|
describe DB::Disposable do
|
|
it "should mark as closed if able to close" do
|
|
obj = ADisposable.new
|
|
obj.closed?.should be_false
|
|
obj.close
|
|
obj.closed?.should be_true
|
|
end
|
|
|
|
it "should not mark as closed if unable to close" do
|
|
obj = ADisposable.new
|
|
obj.raise = true
|
|
obj.closed?.should be_false
|
|
expect_raises Exception do
|
|
obj.close
|
|
end
|
|
obj.closed?.should be_false
|
|
end
|
|
end
|