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

Function usersGetByKeyID

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

Source from the content-addressed store, hash-verified

805}
806
807func usersGetByKeyID(t *testing.T, ctx context.Context, s *UsersStore) {
808 alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{})
809 require.NoError(t, err)
810
811 // TODO: Use PublicKeys.Create to replace SQL hack when the method is available.
812 publicKey := &PublicKey{
813 OwnerID: alice.ID,
814 Name: "test-key",
815 Fingerprint: "12:f8:7e:78:61:b4:bf:e2:de:24:15:96:4e:d4:72:53",
816 Content: "test-key-content",
817 CreatedUnix: s.db.NowFunc().Unix(),
818 UpdatedUnix: s.db.NowFunc().Unix(),
819 }
820 err = s.db.WithContext(ctx).Create(publicKey).Error
821 require.NoError(t, err)
822
823 user, err := s.GetByKeyID(ctx, publicKey.ID)
824 require.NoError(t, err)
825 assert.Equal(t, alice.Name, user.Name)
826
827 _, err = s.GetByKeyID(ctx, publicKey.ID+1)
828 wantErr := ErrUserNotExist{args: errutil.Args{"keyID": publicKey.ID + 1}}
829 assert.Equal(t, wantErr, err)
830}
831
832func usersGetMailableEmailsByUsernames(t *testing.T, ctx context.Context, s *UsersStore) {
833 alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{})

Callers

nothing calls this directly

Calls 2

GetByKeyIDMethod · 0.80
CreateMethod · 0.45

Tested by

no test coverage detected