在我的 Golang 项目中,我需要模拟 mongodb 才能为我的 Repository 函数编写单元测试。我主要需要模拟collection.Indexes.CreateMany
或FindOneAndUpdate
或Find
或cursor.All
或InsertOne
等。据我所知,使用
mtest lib 是可能的。但我无法模拟创建索引。我需要一些关于如何使用mtest
(或是否有更好的选择)在 golang 中模拟 mongo 驱动程序的示例(尤其是collection.FindOneAndUpdate
和collection.Indexes.CreateMany
)的帮助
主页
/
user-3497325