You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
909 B
Go

2 years ago
package binlog
import (
2 years ago
"fmt"
"os"
2 years ago
"testing"
1 year ago
"time"
2 years ago
)
func TestParse(t *testing.T) {
1 year ago
ParseBinlogFile("./test/mysql-bin.000023", func(transaction Transaction) bool {
1 year ago
fmt.Println(transaction)
1 year ago
return true
1 year ago
})
}
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,
1 year ago
}, func(transaction Transaction) bool {
2 years ago
fmt.Println(transaction)
1 year ago
return true
2 years ago
})
2 years ago
}
func TestParseExternal(t *testing.T) {
file := `C:\mysql-bin.000001`
if _, err := os.Stat(file); err != nil {
return
}
1 year ago
i := 0
ParseBinlogWithFilter(file, 0, BinlogFilter{
1 year ago
OnlyShowGtid: false,
}, func(transaction Transaction) bool {
fmt.Println(transaction)
1 year ago
i++
if i >= 10 {
return false
}
return true
})
}