@@ -21,7 +21,6 @@ import (
2121 "testing"
2222
2323 "github.com/dolthub/go-mysql-server/sql"
24- "github.com/dolthub/go-mysql-server/sql/binlogreplication"
2524 "github.com/dolthub/go-mysql-server/sql/plan"
2625 "github.com/dolthub/go-mysql-server/sql/types"
2726 "github.com/dolthub/vitess/go/mysql"
@@ -36,7 +35,7 @@ func TestBuildBinlog_InvalidBase64(t *testing.T) {
3635
3736 _ , err := builder .buildBinlog (ctx , binlogNode , nil )
3837 require .Error (t , err )
39- require .Contains (t , err .Error (), "BinlogReplicaController " )
38+ require .Contains (t , err .Error (), "BinlogConsumer " )
4039}
4140
4241func TestBuildBinlog_NoBinlogReplicaController (t * testing.T ) {
@@ -52,57 +51,33 @@ func TestBuildBinlog_NoBinlogReplicaController(t *testing.T) {
5251
5352 _ , err := builder .buildBinlog (ctx , binlogNode , nil )
5453 require .Error (t , err )
55- require .Contains (t , err .Error (), "BinlogReplicaController " )
54+ require .Contains (t , err .Error (), "BinlogConsumer " )
5655}
5756
58- // mockBinlogReplicaController is a test implementation of BinlogReplicaController
59- type mockBinlogReplicaController struct {
57+ // mockBinlogConsumer is a test implementation of BinlogConsumer
58+ type mockBinlogConsumer struct {
6059 consumedEvents []mysql.BinlogEvent
6160 returnError error
6261 hasFormatDesc bool
6362}
6463
65- func (m * mockBinlogReplicaController ) ConsumeBinlogEvent (ctx * sql.Context , event mysql.BinlogEvent ) error {
64+ func (m * mockBinlogConsumer ) ProcessEvent (ctx * sql.Context , event mysql.BinlogEvent ) error {
6665 m .consumedEvents = append (m .consumedEvents , event )
6766 if event .IsFormatDescription () {
6867 m .hasFormatDesc = true
6968 }
7069 return m .returnError
7170}
7271
73- func (m * mockBinlogReplicaController ) HasFormatDescription () bool {
72+ func (m * mockBinlogConsumer ) HasFormatDescription () bool {
7473 return m .hasFormatDesc
7574}
7675
77- func (m * mockBinlogReplicaController ) StartReplica (ctx * sql.Context ) error {
78- return nil
79- }
80-
81- func (m * mockBinlogReplicaController ) StopReplica (ctx * sql.Context ) error {
82- return nil
83- }
84-
85- func (m * mockBinlogReplicaController ) SetReplicationSourceOptions (ctx * sql.Context , options []binlogreplication.ReplicationOption ) error {
86- return nil
87- }
88-
89- func (m * mockBinlogReplicaController ) SetReplicationFilterOptions (ctx * sql.Context , options []binlogreplication.ReplicationOption ) error {
90- return nil
91- }
92-
93- func (m * mockBinlogReplicaController ) GetReplicaStatus (ctx * sql.Context ) (* binlogreplication.ReplicaStatus , error ) {
94- return nil , nil
95- }
96-
97- func (m * mockBinlogReplicaController ) ResetReplica (ctx * sql.Context , resetAll bool ) error {
98- return nil
99- }
100-
10176func TestBuildBinlog_WithBinlogReplicaController (t * testing.T ) {
10277 builder := & BaseBuilder {}
10378 ctx := sql .NewEmptyContext ()
10479
105- mockController := & mockBinlogReplicaController {}
80+ mockConsumer := & mockBinlogConsumer {}
10681
10782 // Create a minimal valid binlog event (FORMAT_DESCRIPTION_EVENT)
10883 // Event header: timestamp(4) + type(1) + server_id(4) + event_length(4) + next_position(4) + flags(2)
@@ -112,7 +87,7 @@ func TestBuildBinlog_WithBinlogReplicaController(t *testing.T) {
11287
11388 encoded := base64 .StdEncoding .EncodeToString (eventData )
11489
115- binlogNode := plan .NewBinlog (encoded ).WithBinlogReplicaController ( mockController ).(* plan.Binlog )
90+ binlogNode := plan .NewBinlog (encoded ).WithBinlogConsumer ( mockConsumer ).(* plan.Binlog )
11691
11792 iter , err := builder .buildBinlog (ctx , binlogNode , nil )
11893 require .NoError (t , err )
@@ -124,7 +99,7 @@ func TestBuildBinlog_WithBinlogReplicaController(t *testing.T) {
12499 require .Equal (t , types.OkResult {}, row [0 ])
125100
126101 // Verify controller received one event
127- require .Len (t , mockController .consumedEvents , 1 )
102+ require .Len (t , mockConsumer .consumedEvents , 1 )
128103
129104 // Next call should return EOF
130105 _ , err = iter .Next (ctx )
@@ -135,7 +110,7 @@ func TestBuildBinlog_MultilineBase64WithController(t *testing.T) {
135110 builder := & BaseBuilder {}
136111 ctx := sql .NewEmptyContext ()
137112
138- mockController := & mockBinlogReplicaController {}
113+ mockConsumer := & mockBinlogConsumer {}
139114
140115 // Create two minimal events
141116 event1 := make ([]byte , 19 )
@@ -151,7 +126,7 @@ func TestBuildBinlog_MultilineBase64WithController(t *testing.T) {
151126 part2 := base64 .StdEncoding .EncodeToString (combined [10 :])
152127 multiline := part1 + "\n " + part2
153128
154- binlogNode := plan .NewBinlog (multiline ).WithBinlogReplicaController ( mockController ).(* plan.Binlog )
129+ binlogNode := plan .NewBinlog (multiline ).WithBinlogConsumer ( mockConsumer ).(* plan.Binlog )
155130
156131 iter , err := builder .buildBinlog (ctx , binlogNode , nil )
157132 require .NoError (t , err )
@@ -162,7 +137,7 @@ func TestBuildBinlog_MultilineBase64WithController(t *testing.T) {
162137 require .NotNil (t , row )
163138 require .Equal (t , types.OkResult {}, row [0 ])
164139
165- require .Len (t , mockController .consumedEvents , 2 )
140+ require .Len (t , mockConsumer .consumedEvents , 2 )
166141
167142 _ , err = iter .Next (ctx )
168143 require .Equal (t , io .EOF , err )
@@ -172,7 +147,7 @@ func TestBuildBinlog_ControllerError(t *testing.T) {
172147 builder := & BaseBuilder {}
173148 ctx := sql .NewEmptyContext ()
174149
175- mockController := & mockBinlogReplicaController {
150+ mockConsumer := & mockBinlogConsumer {
176151 returnError : sql .ErrUnsupportedFeature .New ("test error" ),
177152 }
178153
@@ -181,7 +156,7 @@ func TestBuildBinlog_ControllerError(t *testing.T) {
181156 binary .LittleEndian .PutUint32 (eventData [9 :13 ], 19 )
182157 encoded := base64 .StdEncoding .EncodeToString (eventData )
183158
184- binlogNode := plan .NewBinlog (encoded ).WithBinlogReplicaController ( mockController ).(* plan.Binlog )
159+ binlogNode := plan .NewBinlog (encoded ).WithBinlogConsumer ( mockConsumer ).(* plan.Binlog )
185160
186161 iter , err := builder .buildBinlog (ctx , binlogNode , nil )
187162 require .NoError (t , err )
0 commit comments