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: authors:
- Brian J. Cardiff <bcardiff@manas.tech> - Brian J. Cardiff <bcardiff@manas.tech>
crystal: 0.22.0 crystal: 0.24.0
license: MIT license: MIT

View file

@ -153,7 +153,7 @@ describe DB::Database do
connection = uninitialized DB::Connection connection = uninitialized DB::Connection
with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db| with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db|
connection = DummyDriver::DummyConnection.connections.first connection = DummyDriver::DummyConnection.connections.first
expect_raises do expect_raises DB::Error do
db.prepared.exec("syntax error") db.prepared.exec("syntax error")
end end
db.pool.is_available?(connection).should be_true db.pool.is_available?(connection).should be_true
@ -164,7 +164,7 @@ describe DB::Database do
connection = uninitialized DB::Connection connection = uninitialized DB::Connection
with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db| with_dummy "dummy://localhost:1027?initial_pool_size=1" do |db|
connection = DummyDriver::DummyConnection.connections.first connection = DummyDriver::DummyConnection.connections.first
expect_raises do expect_raises DB::Error do
db.unprepared.exec("syntax error") db.unprepared.exec("syntax error")
end end
db.pool.is_available?(connection).should be_true 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) def initialize(connection, @query : String, @prepared : Bool)
@params = Hash(Int32 | String, DB::Any).new @params = Hash(Int32 | String, DB::Any).new
super(connection) super(connection)
raise query if query == "syntax error" raise DB::Error.new(query) if query == "syntax error"
end end
protected def perform_query(args : Enumerable) protected def perform_query(args : Enumerable)
@ -111,7 +111,7 @@ class DummyDriver < DB::Driver
protected def perform_exec(args : Enumerable) protected def perform_exec(args : Enumerable)
@connection.as(DummyConnection).check @connection.as(DummyConnection).check
set_params args 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 DB::ExecResult.new 0i64, 0_i64
end end

View file

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

View file

@ -87,15 +87,21 @@ describe "DB.mapping" do
end end
it "should fail to initialize a simple mapping if types do not match" do 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 end
it "should fail to initialize a simple mapping if there is a missing column" do 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 end
it "should fail to initialize a simple mapping if there is an unexpected column" do 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 end
it "should initialize a non-strict mapping if there is an unexpected column" do 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 it "connection should be released if error occurs during exec" do
with_dummy do |db| with_dummy do |db|
expect_raises do expect_raises DB::Error do
db.exec "raise" db.exec "raise"
end end
DummyDriver::DummyConnection.connections.size.should eq(1) DummyDriver::DummyConnection.connections.size.should eq(1)