Updates for crystal 0.24.0

This commit is contained in:
Brian J. Cardiff 2017-12-22 09:12:07 -03:00
parent 790b587e3f
commit ac083f430a
6 changed files with 16 additions and 10 deletions

View file

@ -4,6 +4,6 @@ version: 0.4.4
authors:
- Brian J. Cardiff <bcardiff@manas.tech>
crystal: 0.22.0
crystal: 0.24.0
license: MIT

View file

@ -153,7 +153,7 @@ describe DB::Database do
connection = uninitialized DB::Connection
with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db|
connection = DummyDriver::DummyConnection.connections.first
expect_raises do
expect_raises DB::Error do
db.prepared.exec("syntax error")
end
db.pool.is_available?(connection).should be_true
@ -164,7 +164,7 @@ describe DB::Database do
connection = uninitialized DB::Connection
with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db|
connection = DummyDriver::DummyConnection.connections.first
expect_raises do
expect_raises DB::Error do
db.unprepared.exec("syntax error")
end
db.pool.is_available?(connection).should be_true

View file

@ -99,7 +99,7 @@ class DummyDriver < DB::Driver
def initialize(connection, @query : String, @prepared : Bool)
@params = Hash(Int32 | String, DB::Any).new
super(connection)
raise query if query == "syntax error"
raise DB::Error.new(query) if query == "syntax error"
end
protected def perform_query(args : Enumerable)
@ -111,7 +111,7 @@ class DummyDriver < DB::Driver
protected def perform_exec(args : Enumerable)
@connection.as(DummyConnection).check
set_params args
raise "forced exception due to query" if @query == "raise"
raise DB::Error.new("forced exception due to query") if @query == "raise"
DB::ExecResult.new 0i64, 0_i64
end

View file

@ -278,7 +278,7 @@ describe DummyDriver do
it "should raise executing raise query" do
with_dummy do |db|
expect_raises do
expect_raises DB::Error do
db.exec "raise"
end
end

View file

@ -87,15 +87,21 @@ describe "DB.mapping" do
end
it "should fail to initialize a simple mapping if types do not match" do
expect_raises { from_dummy("b,a", SimpleMapping) }
expect_raises ArgumentError do
from_dummy("b,a", SimpleMapping)
end
end
it "should fail to initialize a simple mapping if there is a missing column" do
expect_raises { from_dummy("1", SimpleMapping) }
expect_raises DB::MappingException do
from_dummy("1", SimpleMapping)
end
end
it "should fail to initialize a simple mapping if there is an unexpected column" do
expect_raises { from_dummy("1,a,b", SimpleMapping) }
expect_raises DB::MappingException do
from_dummy("1,a,b", SimpleMapping)
end
end
it "should initialize a non-strict mapping if there is an unexpected column" do

View file

@ -147,7 +147,7 @@ describe DB::Statement do
it "connection should be released if error occurs during exec" do
with_dummy do |db|
expect_raises do
expect_raises DB::Error do
db.exec "raise"
end
DummyDriver::DummyConnection.connections.size.should eq(1)