Skip to content

Commit

Permalink
PMM-12429 Use a configuration file for mockery (v2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Feb 22, 2024
1 parent d2227cd commit f469356
Show file tree
Hide file tree
Showing 142 changed files with 2,187 additions and 5,156 deletions.
129 changes: 129 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# This is the top-level configuration file for mockery.
disable-version-string: True
with-expecter: False
inpackage: True
dir: "{{.InterfaceDir}}"
filename: "mock_{{ .InterfaceName | snakecase }}_test.go"
mockname: "mock{{ .InterfaceName | camelcase }}"
packages:
# managed
github.com/percona/pmm/managed/services/backup:
interfaces:
agentService:
compatibilityService:
jobsService:
pbmPITRService:
removalService:
Storage:
config:
mockname: "Mock{{ .InterfaceName | camelcase }}"
versioner:
github.com/percona/pmm/managed/services/checks:
interfaces:
agentsRegistry:
github.com/percona/pmm/managed/services/grafana:
interfaces:
awsInstanceChecker:
github.com/percona/pmm/managed/services/inventory:
interfaces:
agentService:
agentsRegistry:
agentsStateUpdater:
connectionChecker:
inventoryMetrics:
prometheusService:
serviceInfoBroker:
versionCache:
github.com/percona/pmm/managed/services/management:
interfaces:
agentsRegistry:
agentsStateUpdater:
apiKeyProvider:
checksService:
connectionChecker:
grafanaClient:
jobsService:
prometheusService:
serviceInfoBroker:
versionCache:
victoriaMetricsClient:
github.com/percona/pmm/managed/services/management/alerting:
interfaces:
grafanaClient:
github.com/percona/pmm/managed/services/management/dbaas:
interfaces:
KubeClientConnector:
config:
mockname: "Mock{{ .InterfaceName | camelcase }}"
dbaasClient:
versionService:
grafanaClient:
componentsService:
kubernetesClient:
kubeStorageManager:
github.com/percona/pmm/managed/services/management/dump:
interfaces:
dumpService:
github.com/percona/pmm/managed/services/management/ia:
interfaces:
alertManager:
vmAlert:
templatesService:
github.com/percona/pmm/managed/services/management/backup:
interfaces:
awsS3:
backupService:
scheduleService:
removalService:
pbmPITRService:
github.com/percona/pmm/managed/services/qan:
interfaces:
qanCollectorClient:
github.com/percona/pmm/managed/services/scheduler:
interfaces:
backupService:
github.com/percona/pmm/managed/services/server:
interfaces:
agentsStateUpdater:
alertmanagerService:
checksService:
emailer:
grafanaClient:
prometheusService:
rulesService:
supervisordService:
telemetryService:
templatesService:
vmAlertExternalRules:
github.com/percona/pmm/managed/services/versioncache:
interfaces:
Versioner:
config:
mockname: "Mock{{ .InterfaceName | camelcase }}"
github.com/percona/pmm/managed/services/telemetry:
interfaces:
DataSource:
DataSourceLocator:
distributionUtilService:
sender:
# admin
github.com/percona/pmm/admin/commands/pmm/server/docker:
interfaces:
Functions:
config:
mockname: "Mock{{ .InterfaceName | camelcase }}"
# agent
github.com/percona/pmm/agent/agentlocal:
interfaces:
client:
supervisor:
github.com/percona/pmm/agent/client:
interfaces:
connectionChecker:
serviceInfoBroker:
supervisor:
github.com/percona/pmm/agent/versioner:
interfaces:
ExecFunctions:
config:
mockname: "Mock{{ .InterfaceName | camelcase }}"
6 changes: 6 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ gen: clean ## Generate files
make -C admin gen
make -C managed gen

make gen-mocks ## Generate mocks

make format
make format ## TODO: One formatting run is not enough, figure out why.
go install -v ./...

gen-mocks:
find . -name mock_*.go -delete
./bin/mockery --config .mockery.yaml

gen-api: ## Generate PMM API
# generated by descriptors target
bin/buf breaking --against descriptor.bin api
Expand Down
1 change: 0 additions & 1 deletion admin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ gen: clean ## Generate files

clean: ## Remove generated files
find . -name *_reform.go -delete
find . -name mock_*.go -delete

release: ## Build pmm-admin release binary
env CGO_ENABLED=0 go build -v $(LD_FLAGS) -o $(PMM_RELEASE_PATH)/pmm-admin ./cmd/pmm-admin/
Expand Down
2 changes: 0 additions & 2 deletions admin/commands/pmm/server/docker/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"github.com/percona/pmm/admin/pkg/docker"
)

//go:generate ../../../../../bin/mockery --name=Functions --case=snake --inpackage --testonly

// Functions contain methods required to interact with Docker.
type Functions interface { //nolint:interfacebloat
Imager
Expand Down
2 changes: 1 addition & 1 deletion admin/commands/pmm/server/docker/mock_functions_test.go

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

1 change: 0 additions & 1 deletion agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ gen: clean ## Generate files

clean: ## Remove generated files
find . -name *_reform.go -delete
find . -name mock_*.go -delete

# generate stub models for perfschema QAN agent; hidden from help as it is not generally useful
gen-init:
Expand Down
3 changes: 0 additions & 3 deletions agent/agentlocal/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import (
"github.com/percona/pmm/api/agentpb"
)

//go:generate ../../bin/mockery --name=client --case=snake --inpackage --testonly
//go:generate ../../bin/mockery --name=supervisor --case=snake --inpackage --testonly

// client is a subset of methods of client.Client used by this package.
// We use it instead of real type for testing and to avoid dependency cycle.
type client interface {
Expand Down
2 changes: 1 addition & 1 deletion agent/agentlocal/mock_client_test.go

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

2 changes: 1 addition & 1 deletion agent/agentlocal/mock_supervisor_test.go

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

4 changes: 0 additions & 4 deletions agent/client/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import (
"github.com/percona/pmm/api/agentpb"
)

//go:generate ../../bin/mockery --name=connectionChecker --case=snake --inpackage --testonly
//go:generate ../../bin/mockery --name=serviceInfoBroker --case=snake --inpackage --testonly
//go:generate ../../bin/mockery --name=supervisor --case=snake --inpackage --testonly

// connectionChecker is a subset of methods of connectionchecker.ConnectionChecker used by this package.
// We use it instead of real type for testing and to avoid dependency cycle.
type connectionChecker interface {
Expand Down
2 changes: 1 addition & 1 deletion agent/client/mock_connection_checker_test.go

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

2 changes: 1 addition & 1 deletion agent/client/mock_service_info_broker_test.go

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

2 changes: 1 addition & 1 deletion agent/client/mock_supervisor_test.go

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

2 changes: 1 addition & 1 deletion agent/versioner/mock_exec_functions_test.go

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

2 changes: 0 additions & 2 deletions agent/versioner/versioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ type CombinedOutputer interface {
CombinedOutput() ([]byte, error)
}

//go:generate ../../bin/mockery --name=ExecFunctions --case=snake --inpackage --testonly

// ExecFunctions is an interface for the LookPath() and CommandContext() functions.
type ExecFunctions interface {
LookPath(file string) (string, error)
Expand Down
24 changes: 20 additions & 4 deletions api/agentlocalpb/agentlocal.pb.gw.go

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

Loading

0 comments on commit f469356

Please sign in to comment.