Skip to content

Commit

Permalink
unify the usage of mock logger in tests (#6240) (#6267)
Browse files Browse the repository at this point in the history
Co-authored-by: Malyue <[email protected]>
  • Loading branch information
erda-bot and Malyue authored Feb 4, 2024
1 parent e4e7a66 commit 54854c0
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 2,082 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/elastic/cloud-on-k8s/v2 v2.0.0-20221101080201-221fa719f43b
github.com/elazarl/goproxy v0.0.0-20200421181703-e76ad31c14f6
github.com/erda-project/erda-infra v1.0.9-0.20231213094429-67b1657b3593
github.com/erda-project/erda-infra v1.0.10-0.20240112020002-e4c6c25a3fcf
github.com/erda-project/erda-infra/tools v0.0.0-20231213094429-67b1657b3593
github.com/erda-project/erda-oap-thirdparty-protocol v0.0.0-20210907135609-15886a136d5b
github.com/erda-project/erda-proto-go v1.4.0
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 h1:Etfj2lhXyrY
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6/go.mod h1:YzuYAe2hrrwKXkM9kqjbkTLlkbA+/xw2MA46f1+ENxc=
github.com/ClickHouse/ch-go v0.53.0 h1:gD9oP15FW+1oTTYyVzmuVfM+bk5cB5wqdscBIIw/mRA=
github.com/ClickHouse/ch-go v0.53.0/go.mod h1:B9htMJ0hii/zrC2hljUKdnagRBuLqtRG/GrU3jqCwRk=
github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
github.com/ClickHouse/clickhouse-go/v2 v2.10.1 h1:WCnusqEeCO/9sLFVIv57le/O1ydUb+x9+SYYhJ11fsY=
github.com/ClickHouse/clickhouse-go/v2 v2.10.1/go.mod h1:teXfZNM90iQ99Jnuht+dxQXCuhDZ8nvvMoTJOFrcmcg=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
Expand Down Expand Up @@ -296,6 +297,7 @@ github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -563,6 +565,8 @@ github.com/erda-project/elastic v0.0.1-ex h1:5ajfxQ5S5YjpzFqY9LzL9hiKWCn6q/JDT4n
github.com/erda-project/elastic v0.0.1-ex/go.mod h1:iAVsas6fcmt9pxtge1+dErMhecv+RLSXlD4rnZRJVW0=
github.com/erda-project/erda-infra v1.0.9-0.20231213094429-67b1657b3593 h1:foLm8eCYTpjz2yDccu3+oz8fXv536wXn0TR/xhqWmCo=
github.com/erda-project/erda-infra v1.0.9-0.20231213094429-67b1657b3593/go.mod h1:TS2BPw1crvFCMRqIi3gxZSaJvWw/XIjYmISiPJljFPU=
github.com/erda-project/erda-infra v1.0.10-0.20240112020002-e4c6c25a3fcf h1:s15eIENYaTZW6ome6IxfQCSMPsIJPRz7x0SLnSjsV+w=
github.com/erda-project/erda-infra v1.0.10-0.20240112020002-e4c6c25a3fcf/go.mod h1:TS2BPw1crvFCMRqIi3gxZSaJvWw/XIjYmISiPJljFPU=
github.com/erda-project/erda-infra/tools v0.0.0-20231213094429-67b1657b3593 h1:yqny9kVbick5hUsDQJU4yp9rpZBteNf2FKkUxce/2GU=
github.com/erda-project/erda-infra/tools v0.0.0-20231213094429-67b1657b3593/go.mod h1:F+j8QqEq1dFwrKMK1Ab2+b21ZVTfmMwl16az1+EMmVM=
github.com/erda-project/erda-oap-thirdparty-protocol v0.0.0-20210907135609-15886a136d5b h1:GWf2ChasZFerFwQoTokIvjJLWH57ligTSLD2hUb7UWk=
Expand Down Expand Up @@ -1311,6 +1315,7 @@ github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQ
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE=
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM=
github.com/moby/ipvs v1.0.1/go.mod h1:2pngiyseZbIKXNv7hsKj3O9UEz30c53MT9005gt2hxQ=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8=
Expand Down Expand Up @@ -2008,6 +2013,9 @@ go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mI
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo=
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
Expand Down
5 changes: 3 additions & 2 deletions internal/apps/msp/apm/adapter/adapter.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
_ "google.golang.org/grpc"

"github.com/erda-project/erda-proto-go/msp/apm/adapter/pb"
mocklogger "github.com/erda-project/erda/pkg/mock"
)

// //go:generate mockgen -destination=./adapter_logs_test.go -package exporter github.com/erda-project/erda-infra/base/logs Logger
// //go:generate mockgen -destination=./adapter_register_test.go -package exporter github.com/erda-project/erda-infra/pkg/transport Register
func Test_adapterService_GetInstrumentationLibrary(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
logger := NewMockLogger(ctrl)
logger := mocklogger.NewMockLogger(ctrl)
//register := NewMockRegister(ctrl)
pro := &provider{
Cfg: &config{
Expand Down Expand Up @@ -59,7 +60,7 @@ func Test_adapterService_GetInstrumentationLibrary(t *testing.T) {
func Test_adapterService_GetInstrumentationLibraryDocs(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
logger := NewMockLogger(ctrl)
logger := mocklogger.NewMockLogger(ctrl)
//register := NewMockRegister(ctrl)
pro := &provider{
Cfg: &config{
Expand Down
261 changes: 0 additions & 261 deletions internal/apps/msp/apm/adapter/adapter_logs_test.go

This file was deleted.

5 changes: 3 additions & 2 deletions internal/apps/msp/menu/menu.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ import (
"github.com/erda-project/erda/bundle"
"github.com/erda-project/erda/internal/apps/msp/instance/db"
mdb "github.com/erda-project/erda/internal/apps/msp/menu/db"
mocklogger "github.com/erda-project/erda/pkg/mock"
)

// //go:generate mockgen -destination=./menu_register_test.go -package exporter github.com/erda-project/erda-infra/pkg/transport Register
// //go:generate mockgen -destination=./menu_logs_test.go -package exporter github.com/erda-project/erda-infra/base/logs Logger
func Test_menuService_GetMenu(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
logger := NewMockLogger(ctrl)
logger := mocklogger.NewMockLogger(ctrl)
register := NewMockRegister(ctrl)
defer monkey.UnpatchAll()
monkey.Patch((*menuService).composeMSPMenuParams, func(_ *menuService, _ *pb.GetMenuRequest) map[string]string {
Expand Down Expand Up @@ -119,7 +120,7 @@ func Test_menuService_GetMenu(t *testing.T) {
func Test_menuService_GetSetting(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
logger := NewMockLogger(ctrl)
logger := mocklogger.NewMockLogger(ctrl)
register := NewMockRegister(ctrl)
defer monkey.UnpatchAll()
monkey.Patch((*menuService).getEngineConfigs, func(_ *menuService, _ string, _ string) (map[string]map[string]string, error) {
Expand Down
Loading

0 comments on commit 54854c0

Please sign in to comment.