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

Function usersGetEmail

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

Source from the content-addressed store, hash-verified

1195}
1196
1197func usersGetEmail(t *testing.T, ctx context.Context, s *UsersStore) {
1198 const testUserID = 1
1199 const testEmail = "alice@example.com"
1200 _, err := s.GetEmail(ctx, testUserID, testEmail, false)
1201 wantErr := ErrEmailNotExist{
1202 args: errutil.Args{
1203 "email": testEmail,
1204 },
1205 }
1206 assert.Equal(t, wantErr, err)
1207
1208 err = s.AddEmail(ctx, testUserID, testEmail, false)
1209 require.NoError(t, err)
1210 got, err := s.GetEmail(ctx, testUserID, testEmail, false)
1211 require.NoError(t, err)
1212 assert.Equal(t, testEmail, got.Email)
1213
1214 // Should not return if we ask for a different user
1215 _, err = s.GetEmail(ctx, testUserID+1, testEmail, false)
1216 assert.Equal(t, wantErr, err)
1217
1218 // Should not return if we only want activated emails
1219 _, err = s.GetEmail(ctx, testUserID, testEmail, true)
1220 assert.Equal(t, wantErr, err)
1221
1222 err = s.MarkEmailActivated(ctx, testUserID, testEmail)
1223 require.NoError(t, err)
1224 got, err = s.GetEmail(ctx, testUserID, testEmail, true)
1225 require.NoError(t, err)
1226 assert.Equal(t, testEmail, got.Email)
1227}
1228
1229func usersListEmails(t *testing.T, ctx context.Context, s *UsersStore) {
1230 t.Run("list emails with primary email", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

GetEmailMethod · 0.80
AddEmailMethod · 0.80
MarkEmailActivatedMethod · 0.80

Tested by

no test coverage detected