MCPcopy Index your code
hub / github.com/gogs/gogs / usersUseCustomAvatar

Function usersUseCustomAvatar

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

Source from the content-addressed store, hash-verified

1140}
1141
1142func usersUseCustomAvatar(t *testing.T, ctx context.Context, s *UsersStore) {
1143 alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{})
1144 require.NoError(t, err)
1145
1146 avatar, err := public.Files.ReadFile("img/avatar_default.png")
1147 require.NoError(t, err)
1148
1149 avatarPath := userutil.CustomAvatarPath(alice.ID)
1150 _ = os.Remove(avatarPath)
1151 defer func() { _ = os.Remove(avatarPath) }()
1152
1153 err = s.UseCustomAvatar(ctx, alice.ID, avatar)
1154 require.NoError(t, err)
1155
1156 // Make sure avatar is saved and the user flag is updated.
1157 got := osutil.IsFile(avatarPath)
1158 assert.True(t, got)
1159
1160 alice, err = s.GetByID(ctx, alice.ID)
1161 require.NoError(t, err)
1162 assert.True(t, alice.UseCustomAvatar)
1163}
1164
1165func TestIsUsernameAllowed(t *testing.T) {
1166 for name := range reservedUsernames {

Callers

nothing calls this directly

Calls 6

CustomAvatarPathFunction · 0.92
IsFileFunction · 0.92
RemoveMethod · 0.80
UseCustomAvatarMethod · 0.80
GetByIDMethod · 0.65
CreateMethod · 0.45

Tested by

no test coverage detected