MCPcopy Create free account
hub / github.com/gogs/gogs / usersListFollowers

Function usersListFollowers

internal/database/users_test.go:929–958  ·  view source on GitHub ↗
(t *testing.T, ctx context.Context, s *UsersStore)

Source from the content-addressed store, hash-verified

927}
928
929func usersListFollowers(t *testing.T, ctx context.Context, s *UsersStore) {
930 john, err := s.Create(ctx, "john", "john@example.com", CreateUserOptions{})
931 require.NoError(t, err)
932
933 got, err := s.ListFollowers(ctx, john.ID, 1, 1)
934 require.NoError(t, err)
935 assert.Empty(t, got)
936
937 alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{})
938 require.NoError(t, err)
939 bob, err := s.Create(ctx, "bob", "bob@example.com", CreateUserOptions{})
940 require.NoError(t, err)
941
942 err = s.Follow(ctx, alice.ID, john.ID)
943 require.NoError(t, err)
944 err = s.Follow(ctx, bob.ID, john.ID)
945 require.NoError(t, err)
946
947 // First page only has bob
948 got, err = s.ListFollowers(ctx, john.ID, 1, 1)
949 require.NoError(t, err)
950 require.Len(t, got, 1)
951 assert.Equal(t, bob.ID, got[0].ID)
952
953 // Second page only has alice
954 got, err = s.ListFollowers(ctx, john.ID, 2, 1)
955 require.NoError(t, err)
956 require.Len(t, got, 1)
957 assert.Equal(t, alice.ID, got[0].ID)
958}
959
960func usersListFollowings(t *testing.T, ctx context.Context, s *UsersStore) {
961 john, err := s.Create(ctx, "john", "john@example.com", CreateUserOptions{})

Callers

nothing calls this directly

Calls 4

ListFollowersMethod · 0.80
FollowMethod · 0.80
LenMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected