Permalink
Browse files

Merge pull request #37 from sam0x17/master

Support Crystal 0.24.1
  • Loading branch information...
datanoise committed May 31, 2018
2 parents 7dc6ec4 + 739a4af commit 86c9e530c0ac980ed7b15e653746bc5b6f2527fc
Showing with 16 additions and 8 deletions.
  1. +7 −6 spec/bson_spec.cr
  2. +9 −1 spec/uri_spec.cr
  3. +0 −1 src/mongo/host.cr
@@ -43,8 +43,9 @@ end

describe BSON::Timestamp do
it "should be comparable" do
t1 = BSON::Timestamp.new(Time.now.epoch.to_u32, 0)
t2 = BSON::Timestamp.new(Time.now.epoch.to_u32, 1)
t = Time.now
t1 = BSON::Timestamp.new(t.epoch_ms, 1)
t2 = BSON::Timestamp.new(t.epoch_ms, 2)
t2.should be > t1
end
end
@@ -145,7 +146,7 @@ describe BSON do
bson.append_document("doc") do |child|
child.not_nil!["body"] = "document body"
end
expect_raises Exception do
expect_raises(Exception) do
child.not_nil!["v"] = 2
end
end
@@ -197,8 +198,8 @@ describe BSON do
it "should be able to append timestamp" do
t = Time.now
bson = BSON.new
bson["ts"] = BSON::Timestamp.new(t.epoch.to_u32, 1)
bson["ts"].should eq(BSON::Timestamp.new(t.epoch.to_u32, 1))
bson["ts"] = BSON::Timestamp.new(t.epoch_ms, 1)
bson["ts"].should eq(BSON::Timestamp.new(t.epoch_ms, 1))
end

it "should be able to append regex" do
@@ -344,7 +345,7 @@ describe BSON do

it "should error json" do
s = "{ this = wrong }"
expect_raises Exception do
expect_raises(Exception) do
bson = BSON.from_json s
end
end
@@ -10,6 +10,14 @@ describe Mongo::Uri do
host.port.should eq(27017)
end

it "should work with various ports" do
uri = Mongo::Uri.new "mongodb://localhost:1443"
uri.hosts.size.should eq(1)
host = uri.hosts.first
host.host.should eq("localhost")
host.port.should eq(1443)
end

it "should be able to create new uri with host and port" do
uri = Mongo::Uri.new "localhost", 27017
uri.hosts.size.should eq(1)
@@ -25,7 +33,7 @@ describe Mongo::Uri do
end

it "should be able to parse auth_source and auth_mechanism" do
uri = Mongo::Uri.new "mongodb://christian:secret@localhost:27017/?authMechanism=GSSAPI"
uri = Mongo::Uri.new "mongodb://christian:secret@domain.com:27017/?authMechanism=GSSAPI"
uri.auth_mechanism.should eq("GSSAPI")
uri.auth_source.should eq("$external")
uri.username.should eq("christian")
@@ -22,4 +22,3 @@ class Mongo::Host
hosts
end
end

0 comments on commit 86c9e53

Please sign in to comment.