Skip to content

Commit f54e0e5

Browse files
committed
feat: complete test cases
1 parent 31202c5 commit f54e0e5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

canal/canal_test.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,30 @@ import (
1616
)
1717

1818
type canalTestSuite struct {
19+
addr string
1920
suite.Suite
2021
c *Canal
2122
}
2223

24+
type canalTestSuiteOption func(c *canalTestSuite)
25+
26+
func withAddr(addr string) canalTestSuiteOption {
27+
return func(c *canalTestSuite) {
28+
c.addr = addr
29+
}
30+
}
31+
32+
func newCanalTestSuite(opts ...canalTestSuiteOption) *canalTestSuite {
33+
c := new(canalTestSuite)
34+
for _, opt := range opts {
35+
opt(c)
36+
}
37+
return c
38+
}
39+
2340
func TestCanalSuite(t *testing.T) {
24-
suite.Run(t, new(canalTestSuite))
41+
suite.Run(t, newCanalTestSuite())
42+
suite.Run(t, newCanalTestSuite(withAddr(mysql.DEFAULT_IPv6_ADDR)))
2543
}
2644

2745
const (
@@ -37,6 +55,9 @@ const (
3755
func (s *canalTestSuite) SetupSuite() {
3856
cfg := NewDefaultConfig()
3957
cfg.Addr = fmt.Sprintf("%s:%s", *test_util.MysqlHost, *test_util.MysqlPort)
58+
if s.addr != "" {
59+
cfg.Addr = s.addr
60+
}
4061
cfg.User = "root"
4162
cfg.HeartbeatPeriod = 200 * time.Millisecond
4263
cfg.ReadTimeout = 300 * time.Millisecond

mysql/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ const (
172172

173173
const (
174174
DEFAULT_ADDR = "127.0.0.1:3306"
175+
DEFAULT_IPv6_ADDR = "[::1]:3306"
175176
DEFAULT_USER = "root"
176177
DEFAULT_PASSWORD = ""
177178
DEFAULT_FLAVOR = "mysql"

0 commit comments

Comments
 (0)