-
Notifications
You must be signed in to change notification settings - Fork 2
/
assertion_test.go
51 lines (44 loc) · 1.06 KB
/
assertion_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
package pop3_test
import (
"fmt"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
"github.com/genert/pop3"
)
func TestIsOK(t *testing.T) {
testCases := []struct {
message string
expectedResult bool
}{
{"+OK", true},
{"+OK 2 messages", true},
{"-ERR", false},
{"-ERR no such message", false},
}
for _, tt := range testCases {
var tt = tt
t.Run(fmt.Sprintf(`IsOK should return %s for "%s" message`, strconv.FormatBool(tt.expectedResult), tt.message), func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.expectedResult, pop3.IsOK(tt.message))
})
}
}
func TestIsErr(t *testing.T) {
testCases := []struct {
message string
expectedResult bool
}{
{"+OK", false},
{"+OK 2 messages", false},
{"-ERR", true},
{"-ERR no such message", true},
}
for _, tt := range testCases {
var tt = tt
t.Run(fmt.Sprintf(`IsErr should return %s for "%s" message`, strconv.FormatBool(tt.expectedResult), tt.message), func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.expectedResult, pop3.IsErr(tt.message))
})
}
}