ScottPJones / Mongo.jl

Mongo bindings for the Julia programming language
Other
43 stars 21 forks source link

Check if connection is successful #33

Closed felipenoris closed 6 years ago

felipenoris commented 6 years ago

Aparently, the only way to check if a connection was successful is to try insert something in the database:

@testset "Mongo: bad host/port" begin
    client = MongoClient("bad-host-name", 9999)
    collection = MongoCollection(client, "foo", "bar")
    @test_throws ErrorException insert(collection, ("foo" => "bar"))
end

Even a query will return a iterator without errors, but with no data.

There should be a way to check if the connection to the host was successful.