mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-20 15:07:03 +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:
@@ -73,12 +73,22 @@ func TestAutodetect(t *testing.T) {
|
|||||||
userdb, client, a.userdbAddr, a.clientAddr)
|
userdb, client, a.userdbAddr, a.clientAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Close the two sockets, and re-do the test from above: Autodetect
|
// Close the two sockets, and re-do the test from above: Autodetect should
|
||||||
// should work fine against closed sockets.
|
// work fine against closed sockets.
|
||||||
// To implement this test, we should call SetUnlinkOnClose, but
|
// We need to tell Go to keep the socket files around explicitly, as the
|
||||||
// unfortunately that is only available in Go >= 1.8.
|
// default is to delete them since they were creeated by the net library.
|
||||||
// We want to support Go 1.7 for a while as it is in Debian stable; once
|
uL.SetUnlinkOnClose(false)
|
||||||
// Debian stable moves on, we can implement this test easily.
|
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
|
// Autodetect should pick the suggestions passed as parameters (if
|
||||||
// possible).
|
// possible).
|
||||||
@@ -91,9 +101,6 @@ func TestAutodetect(t *testing.T) {
|
|||||||
t.Errorf("Expected autodetect to pick {%q, %q}, but got {%q, %q}",
|
t.Errorf("Expected autodetect to pick {%q, %q}, but got {%q, %q}",
|
||||||
userdb, client, a.userdbAddr, a.clientAddr)
|
userdb, client, a.userdbAddr, a.clientAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
uL.Close()
|
|
||||||
cL.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReload(t *testing.T) {
|
func TestReload(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user