diff --git a/go.mod b/go.mod index ee0bb1c8deb..bcf8a20e4b2 100644 --- a/go.mod +++ b/go.mod @@ -416,6 +416,7 @@ require ( github.com/shabbyrobe/xmlwriter v0.0.0-20200208144257-9fca06d00ffa // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/sykesm/zap-logfmt v0.0.4 github.com/syndtr/goleveldb v1.0.1-0.20190625010220-02440ea7a285 // indirect github.com/tealeg/xlsx v1.0.5 // indirect github.com/tebeka/strftime v0.1.5 // indirect @@ -449,7 +450,7 @@ require ( go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect + go.uber.org/zap v1.27.0 golang.org/x/arch v0.0.0-20190312162104-788fe5ffcd8c // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect @@ -480,9 +481,10 @@ require ( sigs.k8s.io/kustomize/api v0.17.3 // indirect sigs.k8s.io/kustomize/kyaml v0.17.2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - github.com/sykesm/zap-logfmt v0.0.4 // indirect ) +require github.com/agiledragon/gomonkey v2.0.2+incompatible + replace ( erda.cloud/rocketmq => github.com/erda-project/rocketmq-operator v0.0.0-20221222075906-f28c42d7bf23 github.com/containerd/containerd => github.com/containerd/containerd v1.4.4 diff --git a/go.sum b/go.sum index 3fb36a2b2db..e69229b2b92 100644 --- a/go.sum +++ b/go.sum @@ -851,6 +851,8 @@ github.com/WeiZhang555/tabwriter v0.0.0-20200115015932-e5c45f4da38d/go.mod h1:ZT github.com/XSAM/otelsql v0.29.0 h1:pEw9YXXs8ZrGRYfDc0cmArIz9lci5b42gmP5+tA1Huc= github.com/XSAM/otelsql v0.29.0/go.mod h1:d3/0xGIGC5RVEE+Ld7KotwaLy6zDeaF3fLJHOPpdN2w= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw= +github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee h1:0RklYSvekYaIFI9JUx7TFPQvo++TdILmZiV17QI4nXk= github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee/go.mod h1:M9nmO4lBRWR/bBv7UCOmDJ1MB2DVoqz19B4JchDA+K0= @@ -1261,8 +1263,6 @@ github.com/erda-project/influxql v1.1.0-ex h1:NgP5+S5Qo234IVSIJ3N/egvzCNYJURfMAe github.com/erda-project/influxql v1.1.0-ex/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= github.com/erda-project/pyroscope v0.0.0-20240606092854-2db59554165e h1:04gD21EY0lcliBZSj3VfKcJO9NbIWKNliXjKLPkMhLE= github.com/erda-project/pyroscope v0.0.0-20240606092854-2db59554165e/go.mod h1:oKtFRQJCxy228zqyG5fwPGzo3Fbbj0g+3PVT0C4JJqo= -github.com/erda-project/remotedialer v0.2.6-0.20210713103000-da03eb9e4b23 h1:NaKo6voQVqZM6DMBVhcTT4gjd+lr1C3zE17RROspfg0= -github.com/erda-project/remotedialer v0.2.6-0.20210713103000-da03eb9e4b23/go.mod h1:dbzn9NF1JWbGEHL6Q/1KG4KFROILiY/j6wmfF1Np3fk= github.com/erda-project/remotedialer v0.2.6-0.20240718060406-84946a1d17b1 h1:CLdzGplB9VRtYXFleMrPka71u4xjMw8Ayd+8WTwZjDI= github.com/erda-project/remotedialer v0.2.6-0.20240718060406-84946a1d17b1/go.mod h1:dbzn9NF1JWbGEHL6Q/1KG4KFROILiY/j6wmfF1Np3fk= github.com/erda-project/rocketmq-operator v0.0.0-20221222075906-f28c42d7bf23 h1:A2cod4X3yK1YIBbTIf7q1b8+/S6iLwyNVtQ/SOYflQo= diff --git a/internal/apps/msp/resource/deploy/handlers/mysql/mysql_test.go b/internal/apps/msp/resource/deploy/handlers/mysql/mysql_test.go index 29a23b1d6cc..2cebdeb6b1e 100644 --- a/internal/apps/msp/resource/deploy/handlers/mysql/mysql_test.go +++ b/internal/apps/msp/resource/deploy/handlers/mysql/mysql_test.go @@ -19,7 +19,8 @@ import ( "reflect" "testing" - "bou.ke/monkey" + "github.com/agiledragon/gomonkey" + "github.com/stretchr/testify/assert" "github.com/erda-project/erda/apistructs" "github.com/erda-project/erda/internal/apps/msp/instance/db" @@ -83,7 +84,7 @@ func TestCheckIfNeedTmcInstance(t *testing.T) { }, } - monkey.PatchInstanceMethod(reflect.TypeOf(p.InstanceDb), "First", func(DB *db.InstanceDB, where map[string]any) (*db.Instance, bool, error) { + applyFunc := gomonkey.ApplyMethod(reflect.TypeOf(p.InstanceDb), "First", func(DB *db.InstanceDB, where map[string]any) (*db.Instance, bool, error) { return &db.Instance{ Engine: "mysql", Version: "9.0", @@ -93,6 +94,8 @@ func TestCheckIfNeedTmcInstance(t *testing.T) { Config: "", }, false, nil }) + defer applyFunc.Reset() - _, _, _ = p.CheckIfNeedTmcInstance(req, info) + _, _, err := p.CheckIfNeedTmcInstance(req, info) + assert.NoError(t, err) }