(t *testing.T, ctx context.Context, s *UsersStore)
| 1140 | } |
| 1141 | |
| 1142 | func 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 | |
| 1165 | func TestIsUsernameAllowed(t *testing.T) { |
| 1166 | for name := range reservedUsernames { |
nothing calls this directly
no test coverage detected