Skip to content

Commit

Permalink
statistics: better code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Sep 5, 2023
1 parent 35af128 commit be8b49e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions statistics/handle/lockstats/lock_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestInsertIntoStatsTableLocked(t *testing.T) {
// Executed SQL should be:
exec.EXPECT().ExecRestrictedSQL(
gomock.Eq(ctx),
gomock.Eq(useCurrentSession),
useCurrentSession,
gomock.Eq(insertSQL),
gomock.Eq([]interface{}{int64(1), int64(1)}),
)
Expand All @@ -123,7 +123,7 @@ func TestAddLockedTables(t *testing.T) {
// Executed SQL should be:
exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
gomock.Eq("BEGIN PESSIMISTIC"),
)
// Return table 1 is locked.
Expand All @@ -132,33 +132,33 @@ func TestAddLockedTables(t *testing.T) {
rows := []chunk.Row{c.GetRow(0)}
exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
selectSQL,
).Return(rows, nil, nil)

exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
insertSQL,
gomock.Eq([]interface{}{int64(2), int64(2)}),
)
exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
insertSQL,
gomock.Eq([]interface{}{int64(3), int64(3)}),
)

exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
insertSQL,
gomock.Eq([]interface{}{int64(4), int64(4)}),
)

exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
"COMMIT",
)

Expand Down
8 changes: 4 additions & 4 deletions statistics/handle/lockstats/unlock_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestRemoveLockedTables(t *testing.T) {
// Executed SQL should be:
exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
gomock.Eq("BEGIN PESSIMISTIC"),
)

Expand All @@ -190,7 +190,7 @@ func TestRemoveLockedTables(t *testing.T) {
rows := []chunk.Row{c.GetRow(0)}
exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
selectSQL,
).Return(rows, nil, nil)

Expand All @@ -210,14 +210,14 @@ func TestRemoveLockedTables(t *testing.T) {

exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
deleteLockSQL,
gomock.Eq([]interface{}{int64(1)}),
).Return(nil, nil, nil)

exec.EXPECT().ExecRestrictedSQL(
gomock.All(&ctxMatcher{}),
gomock.Eq(useCurrentSession),
useCurrentSession,
"COMMIT",
)

Expand Down

0 comments on commit be8b49e

Please sign in to comment.