feat: 更新服务方法,显式接受用户ID参数,简化上下文调用
This commit is contained in:
@@ -87,7 +87,7 @@ func (s *UserTestSuite) Test_Me() {
|
||||
// Mock context with user ID
|
||||
ctx = context.WithValue(ctx, consts.CtxKeyUser, userID)
|
||||
|
||||
user, err := User.Me(ctx)
|
||||
user, err := User.Me(ctx, userID)
|
||||
So(err, ShouldBeNil)
|
||||
So(user.ID, ShouldEqual, resp.User.ID)
|
||||
So(user.Phone, ShouldEqual, phone)
|
||||
@@ -95,7 +95,7 @@ func (s *UserTestSuite) Test_Me() {
|
||||
|
||||
Convey("should fail without auth", func() {
|
||||
// No user ID in context
|
||||
user, err := User.Me(ctx)
|
||||
user, err := User.Me(ctx, 0)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(user, ShouldBeNil)
|
||||
})
|
||||
@@ -118,11 +118,11 @@ func (s *UserTestSuite) Test_Update() {
|
||||
Bio: "New Bio",
|
||||
Gender: consts.GenderMale,
|
||||
}
|
||||
err := User.Update(ctx, form)
|
||||
err := User.Update(ctx, userID, form)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify
|
||||
u, _ := User.Me(ctx)
|
||||
u, _ := User.Me(ctx, userID)
|
||||
So(u.Nickname, ShouldEqual, "NewName")
|
||||
So(u.Bio, ShouldEqual, "New Bio")
|
||||
So(u.Gender, ShouldEqual, consts.GenderMale)
|
||||
@@ -145,11 +145,11 @@ func (s *UserTestSuite) Test_RealName() {
|
||||
Realname: "张三",
|
||||
IDCard: "123456789012345678",
|
||||
}
|
||||
err := User.RealName(ctx, form)
|
||||
err := User.RealName(ctx, userID, form)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify
|
||||
u, _ := User.Me(ctx)
|
||||
u, _ := User.Me(ctx, userID)
|
||||
So(u.IsRealNameVerified, ShouldBeTrue)
|
||||
})
|
||||
})
|
||||
@@ -175,7 +175,7 @@ func (s *UserTestSuite) Test_GetNotifications() {
|
||||
})
|
||||
|
||||
Convey("should return notifications", func() {
|
||||
list, err := User.GetNotifications(ctx, "all")
|
||||
list, err := User.GetNotifications(ctx, userID, "all")
|
||||
So(err, ShouldBeNil)
|
||||
So(len(list), ShouldEqual, 1)
|
||||
So(list[0].Title, ShouldEqual, "Welcome")
|
||||
|
||||
Reference in New Issue
Block a user