Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Dec 8, 2023
1 parent f0fa6c3 commit ae8a5c6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions go/vt/vttablet/tabletserver/tabletserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,33 @@ func TestTabletServerCommitPrepared(t *testing.T) {
require.NoError(t, err)
}

func TestTabletServerWithNilTarget(t *testing.T) {
// A non-nil target is required when not using a local context.
ctx := tabletenv.LocalContext()
db, tsv := setupTabletServerTest(t, ctx, "")
defer tsv.StopService()
defer db.Close()

executeSQL := "select * from test_table limit 1000"
executeSQLResult := &sqltypes.Result{
Fields: []*querypb.Field{
{Type: sqltypes.VarBinary},
},
Rows: [][]sqltypes.Value{
{sqltypes.NewVarBinary("row01")},
},
}
db.AddQuery(executeSQL, executeSQLResult)

target := (*querypb.Target)(nil)
state, err := tsv.Begin(ctx, target, nil)
require.NoError(t, err)
_, err = tsv.Execute(ctx, target, executeSQL, nil, state.TransactionID, 0, nil)
require.NoError(t, err)
_, err = tsv.Rollback(ctx, target, state.TransactionID)
require.NoError(t, err)
}

func TestSmallerTimeout(t *testing.T) {
testcases := []struct {
t1, t2, want time.Duration
Expand Down

0 comments on commit ae8a5c6

Please sign in to comment.