mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Add spec for DB.connect
Update to crystal-db ~> 0.4.0
This commit is contained in:
parent
bbed6256a6
commit
b43a12fc92
4 changed files with 21 additions and 3 deletions
|
@ -57,4 +57,15 @@ describe Connection do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "opens a connection without the pool" do
|
||||
with_cnn do |cnn|
|
||||
cnn.should be_a(SQLite3::Connection)
|
||||
|
||||
cnn.exec "create table person (name string, age integer)"
|
||||
cnn.exec "insert into person values (\"foo\", 10)"
|
||||
|
||||
cnn.scalar("select count(*) from person").should eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,13 @@ ensure
|
|||
File.delete(DB_FILENAME)
|
||||
end
|
||||
|
||||
def with_cnn(&block : DB::Connection ->)
|
||||
File.delete(DB_FILENAME) rescue nil
|
||||
DB.connect "sqlite3:#{DB_FILENAME}", &block
|
||||
ensure
|
||||
File.delete(DB_FILENAME)
|
||||
end
|
||||
|
||||
def with_db(name, &block : DB::Database ->)
|
||||
File.delete(name) rescue nil
|
||||
DB.open "sqlite3:#{name}", &block
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue