feat: 更新服务方法,显式接受用户ID参数,简化上下文调用
This commit is contained in:
@@ -52,27 +52,27 @@ func (s *TenantTestSuite) Test_Follow() {
|
||||
models.TenantQuery.WithContext(ctx).Create(t)
|
||||
|
||||
Convey("should follow tenant", func() {
|
||||
err := Tenant.Follow(ctx, cast.ToString(t.ID))
|
||||
err := Tenant.Follow(ctx, u.ID, cast.ToString(t.ID))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify stats
|
||||
profile, err := Tenant.GetPublicProfile(ctx, cast.ToString(t.ID))
|
||||
profile, err := Tenant.GetPublicProfile(ctx, u.ID, cast.ToString(t.ID))
|
||||
So(err, ShouldBeNil)
|
||||
So(profile.IsFollowing, ShouldBeTrue)
|
||||
So(profile.Stats.Followers, ShouldEqual, 1)
|
||||
|
||||
// List Followed
|
||||
list, err := Tenant.ListFollowed(ctx)
|
||||
list, err := Tenant.ListFollowed(ctx, u.ID)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(list), ShouldEqual, 1)
|
||||
So(list[0].Name, ShouldEqual, "Tenant A")
|
||||
|
||||
// Unfollow
|
||||
err = Tenant.Unfollow(ctx, cast.ToString(t.ID))
|
||||
err = Tenant.Unfollow(ctx, u.ID, cast.ToString(t.ID))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
// Verify
|
||||
profile, err = Tenant.GetPublicProfile(ctx, cast.ToString(t.ID))
|
||||
profile, err = Tenant.GetPublicProfile(ctx, u.ID, cast.ToString(t.ID))
|
||||
So(err, ShouldBeNil)
|
||||
So(profile.IsFollowing, ShouldBeFalse)
|
||||
So(profile.Stats.Followers, ShouldEqual, 0)
|
||||
|
||||
Reference in New Issue
Block a user