-
Notifications
You must be signed in to change notification settings - Fork 11
/
event_enum_test.go
55 lines (40 loc) · 1.06 KB
/
event_enum_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
package cache
import (
"fmt"
"testing"
"github.com/stretchr/testify/suite"
)
type enumSuite struct {
suite.Suite
}
func (s *enumSuite) SetupSuite() {}
func (s *enumSuite) TearDownSuite() {}
func (s *enumSuite) SetupTest() {}
func (s *enumSuite) TearDownTest() {}
func TestEnumSuite(t *testing.T) {
suite.Run(t, new(enumSuite))
}
func (s *enumSuite) TestString() {
s.Require().Equal("Evict", EventTypeEvict.String())
notExisted := eventType(1000)
s.Require().Equal("eventType(1000)", notExisted.String())
}
func (s *enumSuite) TestParseEventType() {
var typ eventType
var err error
// normal case
typ, err = ParseeventType("Evict")
s.Require().NoError(err)
s.Require().Equal(EventTypeEvict, typ)
// lower case
typ, err = ParseeventType("evict")
s.Require().NoError(err)
s.Require().Equal(EventTypeEvict, typ)
// upper case
typ, err = ParseeventType("NONE")
s.Require().NoError(err)
s.Require().Equal(EventTypeNone, typ)
// err
_, err = ParseeventType("not-existed")
s.Require().Equal(fmt.Errorf("not-existed is not a valid eventType"), err)
}