-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult_test.go
68 lines (62 loc) · 1.72 KB
/
result_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseSendError(t *testing.T) {
{
input := errors.New(`550 5.7.1 [ip 12] a\n5.7.1b,\n5.7.1 c\n5.7.1 this message has been blocked\n5.7.1\n`)
res, err := parseSendError(input)
assert.Nil(t, err)
assert.Equal(t, res, &sendResult{
code: 550,
enhancedCode: enhancedCode{5, 7, 1},
msg: `[ip 12] a\n5.7.1b,\n5.7.1 c\n5.7.1 this message has been blocked\n5.7.1\n`,
})
assert.False(t, res.isTransientFailure())
assert.True(t, res.isPermanentFailure())
assert.False(t, res.shouldTryAltSmtp())
}
{
input := errors.New(`552 5.2.2 a`)
res, err := parseSendError(input)
assert.Nil(t, err)
assert.Equal(t, res, &sendResult{
code: 552,
enhancedCode: enhancedCode{5, 2, 2},
msg: `a`,
})
assert.False(t, res.isTransientFailure())
assert.True(t, res.isPermanentFailure())
assert.False(t, res.shouldTryAltSmtp())
}
}
func TestParseSendErrorShouldTryAltSmtp(t *testing.T) {
{
input := errors.New(`550 5.7.1 a`)
res, err := parseSendError(input)
assert.Nil(t, err)
assert.Equal(t, res, &sendResult{
code: 550,
enhancedCode: enhancedCode{5, 7, 1},
msg: `a`,
})
assert.False(t, res.isTransientFailure())
assert.True(t, res.isPermanentFailure())
assert.True(t, res.shouldTryAltSmtp())
}
{
input := errors.New(`450 4.2.1 a`)
res, err := parseSendError(input)
assert.Nil(t, err)
assert.Equal(t, res, &sendResult{
code: 450,
enhancedCode: enhancedCode{4, 2, 1},
msg: `a`,
})
assert.True(t, res.isTransientFailure())
assert.False(t, res.isPermanentFailure())
assert.True(t, res.shouldTryAltSmtp())
}
}