123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- package mock
- import (
- "context"
- "go-common/app/admin/main/apm/dao"
- cml "go-common/app/admin/main/apm/model/canal"
- "go-common/app/admin/main/apm/model/need"
- "go-common/app/admin/main/apm/model/ecode"
- "go-common/app/admin/main/apm/model/pprof"
- "go-common/app/admin/main/apm/model/ut"
- "reflect"
- "github.com/bouk/monkey"
- )
- // MockDaoSetConfigID .
- func MockDaoSetConfigID(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "SetConfigID", func(_ *dao.Dao, _ int64, _ string) error {
- return err
- })
- }
- // MockDaoCanalInfoCounts .
- func MockDaoCanalInfoCounts(d *dao.Dao, cnt int, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CanalInfoCounts", func(_ *dao.Dao, _ *cml.ConfigReq) (int, error) {
- return cnt, err
- })
- }
- // MockDaoCanalInfoEdit .
- func MockDaoCanalInfoEdit(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CanalInfoEdit", func(_ *dao.Dao, _ *cml.ConfigReq) error {
- return err
- })
- }
- // MockDaoCanalApplyCounts .
- func MockDaoCanalApplyCounts(d *dao.Dao, cnt int, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CanalApplyCounts", func(_ *dao.Dao, _ *cml.ConfigReq) (int, error) {
- return cnt, err
- })
- }
- // MockDaoCanalApplyEdit .
- func MockDaoCanalApplyEdit(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CanalApplyEdit", func(_ *dao.Dao, _ *cml.ConfigReq, _ string) error {
- return err
- })
- }
- // MockDaoCanalApplyCreate .
- func MockDaoCanalApplyCreate(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "CanalApplyCreate", func(_ *dao.Dao, _ *cml.ConfigReq, _ string) error {
- return err
- })
- }
- // MockDaoGetCodes .
- func MockDaoGetCodes(d *dao.Dao, data []*codes.Codes, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetCodes", func(_ *dao.Dao, _ context.Context, _ string, _ string) ([]*codes.Codes, error) {
- return data, err
- })
- }
- // MockDaoNeedInfoAdd .
- func MockDaoNeedInfoAdd(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "NeedInfoAdd", func(_ *dao.Dao, _ *need.NAddReq, _ string) error {
- return err
- })
- }
- // MockDaoNeedInfoList .
- func MockDaoNeedInfoList(d *dao.Dao, res []*need.NInfo, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "NeedInfoList", func(_ *dao.Dao, _ *need.NListReq) ([]*need.NInfo, error) {
- return res, err
- })
- }
- // MockDaoNeedInfoCount .
- func MockDaoNeedInfoCount(d *dao.Dao, count int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "NeedInfoCount", func(_ *dao.Dao, _ *need.NListReq) (int64, error) {
- return count, err
- })
- }
- // MockDaoGetNeedInfo .
- func MockDaoGetNeedInfo(d *dao.Dao, r *need.NInfo, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetNeedInfo", func(_ *dao.Dao, _ int64) (*need.NInfo, error) {
- return r, err
- })
- }
- // MockDaoNeedInfoEdit .
- func MockDaoNeedInfoEdit(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "NeedInfoEdit", func(_ *dao.Dao, _ *need.NEditReq) error {
- return err
- })
- }
- // MockDaoNeedVerify .
- func MockDaoNeedVerify(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "NeedVerify", func(_ *dao.Dao, _ *need.NVerifyReq) error {
- return err
- })
- }
- // MockDaoLikeCountsStats .
- func MockDaoLikeCountsStats(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "LikeCountsStats", func(_ *dao.Dao, _ *need.Likereq, _ int, _ int) error {
- return err
- })
- }
- // MockDaoGetVoteInfo .
- func MockDaoGetVoteInfo(d *dao.Dao, u *need.UserLikes, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetVoteInfo", func(_ *dao.Dao, _ *need.Likereq, _ string) (*need.UserLikes, error) {
- return u, err
- })
- }
- // MockDaoUpdateVoteInfo .
- func MockDaoUpdateVoteInfo(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UpdateVoteInfo", func(_ *dao.Dao, _ *need.Likereq, _ string) error {
- return err
- })
- }
- // MockDaoAddVoteInfo .
- func MockDaoAddVoteInfo(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "AddVoteInfo", func(_ *dao.Dao, _ *need.Likereq, _ string) error {
- return err
- })
- }
- // MockDaoVoteInfoList .
- func MockDaoVoteInfoList(d *dao.Dao, res []*need.UserLikes, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "VoteInfoList", func(_ *dao.Dao, _ *need.Likereq) ([]*need.UserLikes, error) {
- return res, err
- })
- }
- // MockDaoVoteInfoCounts .
- func MockDaoVoteInfoCounts(d *dao.Dao, count int64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "VoteInfoCounts", func(_ *dao.Dao, _ *need.Likereq) (int64, error) {
- return count, err
- })
- }
- // MockDaoInstances .
- func MockDaoInstances(d *dao.Dao, ins *pprof.Ins, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "Instances", func(_ *dao.Dao, _ context.Context, _ string) (*pprof.Ins, error) {
- return ins, err
- })
- }
- // MockDaoGitLabFace .
- func MockDaoGitLabFace(d *dao.Dao, avatarURL string, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GitLabFace", func(_ *dao.Dao, _ context.Context, _ string) (string, error) {
- return avatarURL, err
- })
- }
- // MockDaoUploadProxy .
- func MockDaoUploadProxy(d *dao.Dao, url string, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "UploadProxy", func(_ *dao.Dao, _ context.Context, _ string, _ int64, _ []byte) (string, error) {
- return url, err
- })
- }
- // MockDaoParseUTFiles .
- func MockDaoParseUTFiles(d *dao.Dao, pkgs []*ut.PkgAnls, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "ParseUTFiles", func(_ *dao.Dao, _ context.Context, _ string) ([]*ut.PkgAnls, error) {
- return pkgs, err
- })
- }
- // MockDaoSendWechatToUsers .
- func MockDaoSendWechatToUsers(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "SendWechatToUsers", func(_ *dao.Dao, _ context.Context, _ []string, _ string) error {
- return err
- })
- }
- // MockDaoSendWechatToGroup .
- func MockDaoSendWechatToGroup(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "SendWechatToGroup", func(_ *dao.Dao, _ context.Context, _ string, _ string) error {
- return err
- })
- }
- // MockDaoGitLabCommits .
- func MockDaoGitLabCommits(d *dao.Dao, commit *ut.GitlabCommit, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GitLabCommits", func(_ *dao.Dao, _ context.Context, _ string) (*ut.GitlabCommit, error) {
- return commit, err
- })
- }
- // MockDaoGetCoverage .
- func MockDaoGetCoverage(d *dao.Dao, cov float64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetCoverage", func(_ *dao.Dao, _ context.Context, _ string, _ string) (float64, error) {
- return cov, err
- })
- }
- // MockDaoSetAppCovCache .
- func MockDaoSetAppCovCache(d *dao.Dao, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "SetAppCovCache", func(_ *dao.Dao, _ context.Context) error {
- return err
- })
- }
- // MockDaoGetAppCovCache .
- func MockDaoGetAppCovCache(d *dao.Dao, coverage float64, err error) (guard *monkey.PatchGuard) {
- return monkey.PatchInstanceMethod(reflect.TypeOf(d), "GetAppCovCache", func(_ *dao.Dao, _ context.Context, _ string) (float64, error) {
- return coverage, err
- })
- }
|