mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
use connection_string as database configuration instead of a hash
This commit is contained in:
parent
8c0313a306
commit
a96776e336
6 changed files with 17 additions and 18 deletions
|
@ -7,16 +7,15 @@ describe DB do
|
|||
DB.driver_class("dummy").should eq(DummyDriver)
|
||||
end
|
||||
|
||||
it "should instantiate driver with options" do
|
||||
db = DB.open "dummy", {"host": "localhost", "port": "1027"}
|
||||
it "should instantiate driver with connection_string" do
|
||||
db = DB.open "dummy", "localhost:1027"
|
||||
db.driver_class.should eq(DummyDriver)
|
||||
db.options["host"].should eq("localhost")
|
||||
db.options["port"].should eq("1027")
|
||||
db.connection_string.should eq("localhost:1027")
|
||||
end
|
||||
|
||||
it "should create a connection and close it" do
|
||||
cnn = nil
|
||||
DB.open "dummy", {"host": "localhost"} do |db|
|
||||
DB.open "dummy", "localhost" do |db|
|
||||
cnn = db.connection
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ require "spec"
|
|||
|
||||
class DummyDriver < DB::Driver
|
||||
def build_connection
|
||||
DummyConnection.new(options)
|
||||
DummyConnection.new(connection_string)
|
||||
end
|
||||
|
||||
class DummyConnection < DB::Connection
|
||||
|
@ -152,7 +152,7 @@ def with_witness(count = 1)
|
|||
end
|
||||
|
||||
def with_dummy
|
||||
DB.open "dummy", {} of String => String do |db|
|
||||
DB.open "dummy", "" do |db|
|
||||
yield db
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue