(t *testing.T, ctx context.Context, s *UsersStore)
| 805 | } |
| 806 | |
| 807 | func 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 | |
| 832 | func usersGetMailableEmailsByUsernames(t *testing.T, ctx context.Context, s *UsersStore) { |
| 833 | alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
nothing calls this directly
no test coverage detected