1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

Code style improvements

This patch contains some minor code style improvements, to leave the
linter happier and generally follow best practices in some areas where
things snuck through.
This commit is contained in:
Alberto Bertogli
2018-12-01 10:42:13 +00:00
parent 4296e28074
commit 4db9ffec09
4 changed files with 29 additions and 26 deletions

View File

@@ -110,7 +110,10 @@ func TestSMTP(t *testing.T) {
// lookup whick makes the test more hermetic. This is a hack, ideally we // 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 // would be able to override the default resolver, but Go does not
// implement that yet. // implement that yet.
testMX["to"] = []*net.MX{{":::", 10}, {host, 20}} testMX["to"] = []*net.MX{
{Host: ":::", Pref: 10},
{Host: host, Pref: 20},
}
*smtpPort = port *smtpPort = port
s, tmpDir := newSMTP(t) s, tmpDir := newSMTP(t)

View File

@@ -393,7 +393,8 @@ func (item *Item) deliver(q *Queue, rcpt *Recipient) (err error, permanent bool)
if envelope.DomainIn(rcpt.Address, q.localDomains) { if envelope.DomainIn(rcpt.Address, q.localDomains) {
deliverAttempts.Add("email:local", 1) deliverAttempts.Add("email:local", 1)
return q.localC.Deliver(item.From, rcpt.Address, item.Data) return q.localC.Deliver(item.From, rcpt.Address, item.Data)
} else { }
deliverAttempts.Add("email:remote", 1) deliverAttempts.Add("email:remote", 1)
from := item.From from := item.From
if !envelope.DomainIn(item.From, q.localDomains) { if !envelope.DomainIn(item.From, q.localDomains) {
@@ -414,7 +415,6 @@ func (item *Item) deliver(q *Queue, rcpt *Recipient) (err error, permanent bool)
} }
return q.remoteC.Deliver(from, rcpt.Address, item.Data) return q.remoteC.Deliver(from, rcpt.Address, item.Data)
} }
}
// countRcpt counts how many recipients are in the given status. // countRcpt counts how many recipients are in the given status.
func (item *Item) countRcpt(statuses ...Recipient_Status) int { func (item *Item) countRcpt(statuses ...Recipient_Status) int {

View File

@@ -385,7 +385,7 @@ func TestCacheBadData(t *testing.T) {
} }
} }
func mustFetch(t *testing.T, c *PolicyCache, ctx context.Context, d string) *Policy { func (c *PolicyCache) mustFetch(ctx context.Context, t *testing.T, d string) *Policy {
p, err := c.Fetch(ctx, d) p, err := c.Fetch(ctx, d)
if err != nil { if err != nil {
t.Fatalf("Fetch %q failed: %v", d, err) t.Fatalf("Fetch %q failed: %v", d, err)
@@ -421,7 +421,7 @@ func TestCacheRefresh(t *testing.T) {
mode: enforce mode: enforce
mx: mx mx: mx
max_age: 100` max_age: 100`
p := mustFetch(t, c, ctx, "refresh-test") p := c.mustFetch(ctx, t, "refresh-test")
if p.MaxAge != 100*time.Second { if p.MaxAge != 100*time.Second {
t.Fatalf("policy.MaxAge is %v, expected 100s", p.MaxAge) t.Fatalf("policy.MaxAge is %v, expected 100s", p.MaxAge)
} }
@@ -434,7 +434,7 @@ func TestCacheRefresh(t *testing.T) {
mx: mx mx: mx
max_age: 200` max_age: 200`
p = mustFetch(t, c, ctx, "refresh-test") p = c.mustFetch(ctx, t, "refresh-test")
if p.MaxAge != 100*time.Second { if p.MaxAge != 100*time.Second {
t.Fatalf("policy.MaxAge is %v, expected 100s", p.MaxAge) t.Fatalf("policy.MaxAge is %v, expected 100s", p.MaxAge)
} }
@@ -450,7 +450,7 @@ func TestCacheRefresh(t *testing.T) {
time.Sleep(5 * time.Millisecond) time.Sleep(5 * time.Millisecond)
} }
p = mustFetch(t, c, ctx, "refresh-test") p = c.mustFetch(ctx, t, "refresh-test")
if p.MaxAge != 200*time.Second { if p.MaxAge != 200*time.Second {
t.Fatalf("policy.MaxAge is %v, expected 200s", p.MaxAge) t.Fatalf("policy.MaxAge is %v, expected 200s", p.MaxAge)
} }