MCPcopy
hub / github.com/pingcap/tidb / TestInsertIntoTTLTask

Function TestInsertIntoTTLTask

pkg/ttl/cache/task_test.go:94–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestInsertIntoTTLTask(t *testing.T) {
95 store := testkit.CreateMockStore(t)
96 tk := testkit.NewTestKit(t, store)
97 tk.Session().GetSessionVars().TimeZone = time.Local
98
99 ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnTTL)
100 tg := newTaskGetter(ctx, t, tk)
101
102 rangeStart := []types.Datum{types.NewDatum(1)}
103 rangeEnd := []types.Datum{types.NewDatum(2)}
104
105 now := time.Now()
106 now = now.Round(time.Second)
107
108 sql, args, err := cache.InsertIntoTTLTask(tk.Session(), "test-job", 1, 1,
109 rangeStart, rangeEnd, now, now)
110 require.NoError(t, err)
111 // tk.MustExec cannot handle the NULL parameter, use the `tk.Session().ExecuteInternal` instead here.
112 _, err = tk.Session().ExecuteInternal(ctx, sql, args...)
113 require.NoError(t, err)
114 task := tg.mustGetTestTask()
115 require.Equal(t, "test-job", task.JobID)
116 require.Equal(t, int64(1), task.TableID)
117 require.Equal(t, int64(1), task.ScanID)
118 require.Equal(t, []types.Datum{types.NewDatum(1)}, task.ScanRangeStart)
119 require.Equal(t, []types.Datum{types.NewDatum(2)}, task.ScanRangeEnd)
120 require.Equal(t, now, task.ExpireTime)
121 require.Equal(t, now, task.CreatedTime)
122}

Callers

nothing calls this directly

Calls 12

SessionMethod · 0.95
CreateMockStoreFunction · 0.92
NewTestKitFunction · 0.92
NewDatumFunction · 0.92
InsertIntoTTLTaskFunction · 0.92
newTaskGetterFunction · 0.85
RoundMethod · 0.80
mustGetTestTaskMethod · 0.80
GetSessionVarsMethod · 0.65
NowMethod · 0.65
ExecuteInternalMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected