2023-04-25 18:41:34 +08:00
|
|
|
package binlog
|
|
|
|
|
|
|
|
import (
|
2023-04-29 11:29:29 +08:00
|
|
|
"fmt"
|
2023-06-29 13:16:42 +08:00
|
|
|
"os"
|
2023-04-25 18:41:34 +08:00
|
|
|
"testing"
|
2023-05-24 15:25:31 +08:00
|
|
|
"time"
|
2023-04-25 18:41:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParse(t *testing.T) {
|
2023-05-24 15:25:31 +08:00
|
|
|
ParseBinlogFile("./test/mysql-bin.000023", func(transaction Transaction) {
|
|
|
|
fmt.Println(transaction)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseFilter(t *testing.T) {
|
|
|
|
ParseBinlogWithFilter("./test/mysql-bin.000023", 0, BinlogFilter{
|
|
|
|
IncludeGtid: "",
|
|
|
|
ExcludeGtid: "",
|
|
|
|
StartPos: 0,
|
|
|
|
EndPos: 0,
|
|
|
|
StartDate: time.Time{},
|
|
|
|
EndDate: time.Time{},
|
|
|
|
BigThan: 0,
|
|
|
|
SmallThan: 0,
|
|
|
|
}, func(transaction Transaction) {
|
2023-04-29 11:29:29 +08:00
|
|
|
fmt.Println(transaction)
|
|
|
|
})
|
2023-04-25 18:41:34 +08:00
|
|
|
}
|
2023-06-29 13:16:42 +08:00
|
|
|
|
|
|
|
func TestParseExternal(t *testing.T) {
|
|
|
|
file := `C:\mysql-bin.000001`
|
|
|
|
if _, err := os.Stat(file); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ParseBinlogWithFilter(file, 0, BinlogFilter{
|
|
|
|
OnlyShowGtid: true,
|
|
|
|
}, func(transaction Transaction) {
|
|
|
|
fmt.Println(transaction)
|
|
|
|
})
|
|
|
|
}
|