1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

courier: Make the SMTP test not use the network

One of the SMTP tests was doing an external DNS lookup for a
non-existing host, which is reasonably harmless but makes the test less
hermetic.

This patch changes the non-existing host for an invalid address, which
has the same effect but avoids the network lookup.

This is a hack; ideally we would be able to override the resolver, but
Go does not implement that yet, and changing the code is not worth the
additional complexity.
This commit is contained in:
Alberto Bertogli
2017-07-16 13:24:40 +01:00
parent 5426be5aec
commit 6867859d5c

View File

@@ -84,7 +84,11 @@ func TestSMTP(t *testing.T) {
// Put a non-existing host first, so we check that if the first host
// doesn't work, we try with the rest.
fakeMX["to"] = []string{"nonexistinghost", host}
// The host we use is invalid, to avoid having to do an actual network
// lookup whick makes the test more hermetic. This is a hack, ideally we
// would be able to override the default resolver, but Go does not
// implement that yet.
fakeMX["to"] = []string{":::", host}
*smtpPort = port
s, tmpDir := newSMTP(t)