From 6867859d5c35d0cc95f94e91b48d954e62a07c74 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sun, 16 Jul 2017 13:24:40 +0100 Subject: [PATCH] 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. --- internal/courier/smtp_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/courier/smtp_test.go b/internal/courier/smtp_test.go index 7edef1e..c51d691 100644 --- a/internal/courier/smtp_test.go +++ b/internal/courier/smtp_test.go @@ -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)