Skip to content

Commit

Permalink
*: replace defer clean with t.Cleanup (pingcap#36722)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Aug 1, 2022
1 parent 93a31f0 commit 9a16a8d
Show file tree
Hide file tree
Showing 244 changed files with 3,915 additions and 7,542 deletions.
93 changes: 31 additions & 62 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import (
)

func TestPrepareCacheWithBinding(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)
orgEnable := plannercore.PreparedPlanCacheEnabled()
defer func() {
plannercore.SetPreparedPlanCache(orgEnable)
Expand Down Expand Up @@ -300,8 +299,7 @@ func TestPrepareCacheWithBinding(t *testing.T) {
}

func TestExplain(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -332,8 +330,7 @@ func TestExplain(t *testing.T) {
}

func TestBindSemiJoinRewrite(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -355,8 +352,7 @@ using
}

func TestBindCTEMerge(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -376,8 +372,7 @@ using

// TestBindingSymbolList tests sql with "?, ?, ?, ?", fixes #13871
func TestBindingSymbolList(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -414,8 +409,7 @@ func TestBindingSymbolList(t *testing.T) {
}

func TestDMLSQLBind(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -470,8 +464,7 @@ func TestDMLSQLBind(t *testing.T) {
}

func TestBestPlanInBaselines(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -510,8 +503,7 @@ func TestBestPlanInBaselines(t *testing.T) {
}

func TestErrorBind(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -560,8 +552,7 @@ func TestDMLEvolveBaselines(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -628,8 +619,7 @@ func TestAddEvolveTasks(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -662,8 +652,7 @@ func TestRuntimeHintsInEvolveTasks(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -680,8 +669,7 @@ func TestRuntimeHintsInEvolveTasks(t *testing.T) {
}

func TestDefaultSessionVars(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustQuery(`show variables like "%baselines%"`).Sort().Check(testkit.Rows(
Expand All @@ -695,8 +683,7 @@ func TestDefaultSessionVars(t *testing.T) {
}

func TestCaptureBaselinesScope(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk1 := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -732,8 +719,7 @@ func TestCaptureBaselinesScope(t *testing.T) {
}

func TestStmtHints(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -749,8 +735,7 @@ func TestStmtHints(t *testing.T) {
}

func TestPrivileges(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -773,8 +758,7 @@ func TestHintsSetEvolveTask(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -798,8 +782,7 @@ func TestHintsSetEvolveTask(t *testing.T) {
}

func TestHintsSetID(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -871,8 +854,7 @@ func TestNotEvolvePlanForReadStorageHint(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -915,8 +897,7 @@ func TestNotEvolvePlanForReadStorageHint(t *testing.T) {
}

func TestBindingWithIsolationRead(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -954,8 +935,7 @@ func TestReCreateBindAfterEvolvePlan(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -984,8 +964,7 @@ func TestReCreateBindAfterEvolvePlan(t *testing.T) {
}

func TestInvisibleIndex(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -1019,8 +998,7 @@ func TestInvisibleIndex(t *testing.T) {
}

func TestSPMHitInfo(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1047,8 +1025,7 @@ func TestSPMHitInfo(t *testing.T) {
}

func TestReCreateBind(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down Expand Up @@ -1080,8 +1057,7 @@ func TestReCreateBind(t *testing.T) {
}

func TestExplainShowBindSQL(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1099,8 +1075,7 @@ func TestExplainShowBindSQL(t *testing.T) {
}

func TestDMLIndexHintBind(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1122,8 +1097,7 @@ func TestForbidEvolvePlanBaseLinesBeforeGA(t *testing.T) {
config.CheckTableBeforeDrop = originalVal
}()

store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
err := tk.ExecToErr("set @@tidb_evolve_plan_baselines=0")
Expand All @@ -1137,8 +1111,7 @@ func TestForbidEvolvePlanBaseLinesBeforeGA(t *testing.T) {
}

func TestExplainTableStmts(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1150,8 +1123,7 @@ func TestExplainTableStmts(t *testing.T) {
}

func TestSPMWithoutUseDatabase(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk1 := testkit.NewTestKit(t, store)
Expand All @@ -1176,8 +1148,7 @@ func TestSPMWithoutUseDatabase(t *testing.T) {
}

func TestBindingWithoutCharset(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1191,8 +1162,7 @@ func TestBindingWithoutCharset(t *testing.T) {
}

func TestBindingWithMultiParenthesis(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand All @@ -1214,8 +1184,7 @@ func TestGCBindRecord(t *testing.T) {
bindinfo.Lease = originLease
}()

store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
store, dom := testkit.CreateMockStoreAndDomain(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
Expand Down
Loading

0 comments on commit 9a16a8d

Please sign in to comment.