From 5f15e3fd7ffeeb6e9c7815c2ebc59697a7fa2830 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 11 Nov 2024 21:57:56 -0500 Subject: [PATCH] Unit test tweaks Signed-off-by: Matt Lord --- .../vreplication/replicator_plan_test.go | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletmanager/vreplication/replicator_plan_test.go b/go/vt/vttablet/tabletmanager/vreplication/replicator_plan_test.go index 8525541f0b0..09ace916f11 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/replicator_plan_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/replicator_plan_test.go @@ -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}, @@ -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( @@ -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 {