@@ -2,6 +2,8 @@ defmodule Mongo.ConnectionTest do
2
2
use MongoTest.Case , async: true
3
3
alias Mongo
4
4
5
+ import ExUnit.CaptureLog
6
+
5
7
defp connect do
6
8
assert { :ok , pid } =
7
9
Mongo . start_link ( hostname: "localhost" , database: "mongodb_test" )
@@ -89,7 +91,7 @@ defmodule Mongo.ConnectionTest do
89
91
assert capture_log ( fn ->
90
92
{ :ok , pid } = Mongo . start_link ( opts )
91
93
assert_receive { :EXIT , ^ pid , :killed } , 5000
92
- end )
94
+ end ) =~ "(Mongo.Error) auth failed for user mongodb_admin_user"
93
95
end
94
96
95
97
test "insert_one flags" do
@@ -176,15 +178,17 @@ defmodule Mongo.ConnectionTest do
176
178
end
177
179
178
180
test "auth connection leak" do
179
- # sometimes the function tcp_count() returns 1, so the test fails.
180
- # maybe it is a good idea to wait a second before counting
181
- :timer . sleep ( 1000 )
182
- assert tcp_count ( ) == 0
183
- Enum . each ( 1 .. 10 , fn _ ->
184
- connect_auth_invalid ( )
181
+ assert capture_log ( fn ->
182
+ # sometimes the function tcp_count() returns 1, so the test fails.
183
+ # maybe it is a good idea to wait a second before counting
184
+ :timer . sleep ( 1000 )
185
+ assert tcp_count ( ) == 0
186
+ Enum . each ( 1 .. 10 , fn _ ->
187
+ connect_auth_invalid ( )
188
+ end )
189
+ :timer . sleep ( 1000 )
190
+ # there should be 10 connections with connection_type: :monitor
191
+ assert tcp_count ( ) == 10
185
192
end )
186
- :timer . sleep ( 1000 )
187
- # there should be 10 connections with connection_type: :monitor
188
- assert tcp_count ( ) == 10
189
193
end
190
194
end
0 commit comments