• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 14467761241

15 Apr 2025 11:00AM UTC coverage: 90.28% (-0.007%) from 90.287%
14467761241

push

github

hectorgomezv
Add AddressBooksController tests

3219 of 3876 branches covered (83.05%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

4 existing lines in 2 files now uncovered.

11150 of 12040 relevant lines covered (92.61%)

528.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.27
/src/domain/spaces/address-books/address-book-items.repository.ts
1
import { PostgresDatabaseService } from '@/datasources/db/v2/postgres-database.service';
106✔
2
import { AddressBookItem as DbAddressBookItem } from '@/datasources/spaces/entities/address-book-item.entity.db';
106✔
3
import { AuthPayload } from '@/domain/auth/entities/auth-payload.entity';
4
import { IAddressBookItemsRepository } from '@/domain/spaces/address-books/address-book-items.repository.interface';
5
import type { AddressBookItem } from '@/domain/spaces/address-books/entities/address-book-item.entity';
6
import { Space } from '@/domain/spaces/entities/space.entity';
7
import { ISpacesRepository } from '@/domain/spaces/spaces.repository.interface';
106✔
8
import { IUsersRepository } from '@/domain/users/users.repository.interface';
106✔
9
import { Inject, Injectable, UnauthorizedException } from '@nestjs/common';
106✔
10
import { In } from 'typeorm';
106✔
11

12
@Injectable()
13
export class AddressBookItemsRepository implements IAddressBookItemsRepository {
106✔
14
  constructor(
15
    private readonly db: PostgresDatabaseService,
76✔
16
    @Inject(ISpacesRepository)
17
    private readonly spacesRepository: ISpacesRepository,
76✔
18
    @Inject(IUsersRepository)
19
    private readonly userRepository: IUsersRepository,
76✔
20
  ) {}
21

22
  async findAllBySpaceId(args: {
23
    authPayload: AuthPayload;
24
    spaceId: Space['id'];
25
  }): Promise<Array<AddressBookItem>> {
26
    const space = await this.getSpaceAsMember(args);
22✔
27
    const repository = await this.db.getRepository(DbAddressBookItem);
10✔
28
    return repository.findBy({ space: { id: space.id } });
10✔
29
  }
30

31
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
  upsertMany(args: {
33
    authPayload: AuthPayload;
34
    spaceId: Space['id'];
35
    addressBookItems: Array<AddressBookItem>;
36
  }): Promise<Array<AddressBookItem>> {
UNCOV
37
    throw new Error('Method not implemented.');
×
38
  }
39

40
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
  deleteMany(args: {
42
    authPayload: AuthPayload;
43
    spaceId: Space['id'];
44
    addressBookItemIds: Array<string>;
45
  }): Promise<void> {
UNCOV
46
    throw new Error('Method not implemented.');
×
47
  }
48

49
  private async getSpaceAsMember(args: {
50
    authPayload: AuthPayload;
51
    spaceId: Space['id'];
52
  }): Promise<Space> {
53
    if (!args.authPayload.signer_address) {
22!
UNCOV
54
      throw new UnauthorizedException('Signer address not provided.');
×
55
    }
56
    const signerAddress = args.authPayload.signer_address;
22✔
57
    const { id: userId } =
58
      await this.userRepository.findByWalletAddressOrFail(signerAddress);
22✔
59
    return this.spacesRepository.findOneOrFail({
20✔
60
      where: {
61
        id: args.spaceId,
62
        members: { status: In(['ACTIVE', 'INVITED']), user: { id: userId } },
63
      },
64
    });
65
  }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc