1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-19 14:57:04 +00:00

dovecot: Test autodetection works with closed sockets

We want to test that autodetection works with closed sockets, as we
explicitly support that scenario: chasquid might be up before dovecot
is, and we still want the detection to work.

The code is written that way, but we had no tests for it until now,
because we were blocked on the unix listeners supporting
SetUnlinkOnClose, which appeared in Go 1.8.

Now that the minimum Go version has been raised past that, we can
implement the test.
This commit is contained in:
Alberto Bertogli
2019-07-13 14:06:13 +01:00
parent 9821a17d6c
commit d53d97aba0

View File

@@ -73,12 +73,22 @@ func TestAutodetect(t *testing.T) {
userdb, client, a.userdbAddr, a.clientAddr)
}
// TODO: Close the two sockets, and re-do the test from above: Autodetect
// should work fine against closed sockets.
// To implement this test, we should call SetUnlinkOnClose, but
// unfortunately that is only available in Go >= 1.8.
// We want to support Go 1.7 for a while as it is in Debian stable; once
// Debian stable moves on, we can implement this test easily.
// Close the two sockets, and re-do the test from above: Autodetect should
// work fine against closed sockets.
// We need to tell Go to keep the socket files around explicitly, as the
// default is to delete them since they were creeated by the net library.
uL.SetUnlinkOnClose(false)
uL.Close()
cL.SetUnlinkOnClose(false)
cL.Close()
a = Autodetect("", "")
if a == nil {
t.Errorf("Autodetection failed (closed sockets)")
} else if a.userdbAddr != userdb || a.clientAddr != client {
t.Errorf("Expected autodetect to pick {%q, %q}, but got {%q, %q}",
userdb, client, a.userdbAddr, a.clientAddr)
}
// Autodetect should pick the suggestions passed as parameters (if
// possible).
@@ -91,9 +101,6 @@ func TestAutodetect(t *testing.T) {
t.Errorf("Expected autodetect to pick {%q, %q}, but got {%q, %q}",
userdb, client, a.userdbAddr, a.clientAddr)
}
uL.Close()
cL.Close()
}
func TestReload(t *testing.T) {