Skip to content

Commit

Permalink
disttask: replace manually mock with gomock (#46392)
Browse files Browse the repository at this point in the history
ref #41495
  • Loading branch information
D3Hunter authored Aug 25, 2023
1 parent 685bcaa commit 2f2bc41
Show file tree
Hide file tree
Showing 9 changed files with 733 additions and 416 deletions.
1 change: 1 addition & 0 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ header:
- "build/image/.ci_bazel"
- "**/OWNERS"
- "OWNERS_ALIASES"
- "disttask/framework/mock/*_mock.go"
comment: on-failure
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ mock_lightning:
@mockgen -package mocklocal github.com/pingcap/tidb/br/pkg/lightning/backend/local DiskUsage,TiKVModeSwitcher > br/pkg/mock/mocklocal/local.go
@mockgen -package mock github.com/pingcap/tidb/br/pkg/utils TaskRegister > br/pkg/mock/task_register.go

gen_mock:
@mockgen -package mock github.com/pingcap/tidb/disttask/framework/scheduler TaskTable,SubtaskExecutor,Pool,Scheduler,InternalScheduler > disttask/framework/mock/scheduler_mock.go

# There is no FreeBSD environment for GitHub actions. So cross-compile on Linux
# but that doesn't work with CGO_ENABLED=1, so disable cgo. The reason to have
# cgo enabled on regular builds is performance.
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/mock/mocklocal/local.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions disttask/framework/mock/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "mock",
srcs = ["scheduler_mock.go"],
importpath = "github.com/pingcap/tidb/disttask/framework/mock",
visibility = ["//visibility:public"],
deps = [
"//disttask/framework/proto",
"@org_uber_go_mock//gomock",
],
)
Loading

0 comments on commit 2f2bc41

Please sign in to comment.