Close the connection only if we establish it. (#18897)

This commit is contained in:
gotjosh
2019-09-16 14:13:35 +01:00
committed by GitHub
parent e9f1e86c8e
commit 99c799e9b7
5 changed files with 53 additions and 7 deletions
+4 -2
View File
@@ -40,11 +40,12 @@ func TestMultiLDAP(t *testing.T) {
So(statuses[0].Port, ShouldEqual, 361)
So(statuses[0].Available, ShouldBeFalse)
So(statuses[0].Error, ShouldEqual, expectedErr)
So(mock.closeCalledTimes, ShouldEqual, 0)
teardown()
})
Convey("Shoudl get the LDAP server statuses", func() {
setup()
Convey("Should get the LDAP server statuses", func() {
mock := setup()
multi := New([]*ldap.ServerConfig{
{Host: "10.0.0.1", Port: 361},
@@ -57,6 +58,7 @@ func TestMultiLDAP(t *testing.T) {
So(statuses[0].Port, ShouldEqual, 361)
So(statuses[0].Available, ShouldBeTrue)
So(statuses[0].Error, ShouldBeNil)
So(mock.closeCalledTimes, ShouldEqual, 1)
teardown()
})