Skip to content

Commit

Permalink
Unit test tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Nov 12, 2024
1 parent 5530030 commit 5f15e3f
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions go/vt/vttablet/tabletmanager/vreplication/replicator_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,47 @@ func TestAppendFromRow(t *testing.T) {
wantErr: "wrong number of fields: got 2 fields for 3 bind locations",
},
{
name: "lots o skippin",
name: "skip half",
tp: &TablePlan{
BulkInsertValues: sqlparser.BuildParsedQuery("values (%a, %a, %a)",
":c1", ":c2", ":c4",
BulkInsertValues: sqlparser.BuildParsedQuery("values (%a, %a, %a, %a)",
":c1", ":c2", ":c4", ":c8",
),
Fields: []*querypb.Field{
{Name: "c1", Type: querypb.Type_INT32},
{Name: "c2", Type: querypb.Type_INT32},
{Name: "c3", Type: querypb.Type_INT32},
{Name: "c4", Type: querypb.Type_INT32},
{Name: "c5", Type: querypb.Type_INT32},
{Name: "c6", Type: querypb.Type_INT32},
{Name: "c7", Type: querypb.Type_INT32},
{Name: "c8", Type: querypb.Type_INT32},
},
FieldsToSkip: map[string]bool{
"c3": true,
"c5": true,
"c6": true,
"c7": true,
},
},
row: sqltypes.RowToProto3(
[]sqltypes.Value{
sqltypes.NewInt64(1),
sqltypes.NewInt64(2),
sqltypes.NewInt64(3),
sqltypes.NewInt64(4),
sqltypes.NewInt64(5),
sqltypes.NewInt64(6),
sqltypes.NewInt64(7),
sqltypes.NewInt64(8),
},
),
want: "values (1, 2, 4, 8)",
},
{
name: "skip all but one",
tp: &TablePlan{
BulkInsertValues: sqlparser.BuildParsedQuery("values (%a)",
":c4",
),
Fields: []*querypb.Field{
{Name: "c1", Type: querypb.Type_INT32},
Expand All @@ -887,12 +924,16 @@ func TestAppendFromRow(t *testing.T) {
{Name: "c5", Type: querypb.Type_INT32},
{Name: "c6", Type: querypb.Type_INT32},
{Name: "c7", Type: querypb.Type_INT32},
{Name: "c8", Type: querypb.Type_INT32},
},
FieldsToSkip: map[string]bool{
"c1": true,
"c2": true,
"c3": true,
"c5": true,
"c6": true,
"c7": true,
"c8": true,
},
},
row: sqltypes.RowToProto3(
Expand All @@ -904,9 +945,10 @@ func TestAppendFromRow(t *testing.T) {
sqltypes.NewInt64(5),
sqltypes.NewInt64(6),
sqltypes.NewInt64(7),
sqltypes.NewInt64(8),
},
),
want: "values (1, 2, 4)",
want: "values (4)",
},
}
for _, tc := range testCases {
Expand Down

0 comments on commit 5f15e3f

Please sign in to comment.