-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathrows_test.go
61 lines (59 loc) · 1.38 KB
/
rows_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
56
57
58
59
60
61
package canal
import (
"github.com/go-mysql-org/go-mysql/replication"
"github.com/go-mysql-org/go-mysql/schema"
"reflect"
"testing"
)
func TestRowsEvent_handleUnsigned(t *testing.T) {
type fields struct {
Table *schema.Table
Action string
Rows [][]interface{}
Header *replication.EventHeader
}
tests := []struct {
name string
fields fields
wantRows [][]interface{}
}{
{
name: "rows_event_handle_unsigned",
fields: fields{
Table: &schema.Table{
// columns 1,3,5,7,9 should be converted from signed to unsigned,
// column 10 is out of range and should be ignored, don't panic.
UnsignedColumns: []int{1, 3, 5, 7, 9, 10},
},
Rows: [][]interface{}{{
int8(8), int8(8),
int16(16), int16(16),
int32(32), int32(32),
int64(64), int64(64),
int(128), int(128)},
},
},
wantRows: [][]interface{}{{
int8(8), uint8(8),
int16(16), uint16(16),
int32(32), uint32(32),
int64(64), uint64(64),
int(128), uint(128)},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := &RowsEvent{
Table: tt.fields.Table,
Action: tt.fields.Action,
Rows: tt.fields.Rows,
Header: tt.fields.Header,
}
r.handleUnsigned()
if !reflect.DeepEqual(tt.fields.Rows, tt.wantRows) {
t.Errorf("rows=%+v, wantRows=%+v, not equal", tt.fields.Rows, tt.wantRows)
}
})
}
}