mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 14:06:27 +00:00
8350d04a63
UserImmichRepository, UserSynologyRepository and UserAirtrailRepository hold the eighteen connection statements UsersRepository carried, on the same users table and with their statements unchanged, provided through a small module as factories over the EntityManager. ImmichService, SynologyService, AirtrailService and JourneyService inject them instead of the account repository. UserRow drops the dead immich_access_token column (the table keeps it), and a shape test pins the account repository's size.
40 lines
2.2 KiB
TypeScript
40 lines
2.2 KiB
TypeScript
/**
|
|
* UsersRepository had grown to 84 methods, a fifth of them for the third-party
|
|
* connections a user keeps on their row. Those now live in their own
|
|
* repositories on the same table (UserImmich/UserSynology/UserAirtrail). This
|
|
* pins the account repository's size so a new connection's statements land in
|
|
* a repository of their own, and pins which columns each connection repository
|
|
* is about, so a statement on another column does not drift into it.
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
import { UsersRepository } from '../../../src/db/repositories/Users.repository';
|
|
import { UserImmichRepository } from '../../../src/db/repositories/UserImmich.repository';
|
|
import { UserSynologyRepository } from '../../../src/db/repositories/UserSynology.repository';
|
|
import { UserAirtrailRepository } from '../../../src/db/repositories/UserAirtrail.repository';
|
|
|
|
const ownMethods = (cls: { prototype: object }) =>
|
|
Object.getOwnPropertyNames(cls.prototype).filter((name) => name !== 'constructor').sort();
|
|
|
|
describe('the users repositories', () => {
|
|
it('USERSHAPE-001: UsersRepository holds no more methods than it does today', () => {
|
|
// Lower this when a method leaves; a new integration gets its own repository.
|
|
expect(ownMethods(UsersRepository).length).toBeLessThanOrEqual(66);
|
|
});
|
|
|
|
it('USERSHAPE-002: no connection statement is left on UsersRepository', () => {
|
|
expect(ownMethods(UsersRepository).filter((name) => /immich|synology|airtrail/i.test(name))).toEqual([]);
|
|
});
|
|
|
|
it('USERSHAPE-003: each connection repository holds its own statements', () => {
|
|
expect(ownMethods(UserImmichRepository)).toEqual(
|
|
['clearImmichSettings', 'getImmichAutoUpload', 'getImmichConnectionPrefs', 'getImmichCredentials', 'setImmichAutoUpload', 'setImmichSettings'],
|
|
);
|
|
expect(ownMethods(UserSynologyRepository)).toEqual(
|
|
['clearSynologySID', 'clearSynologySession', 'getSynologyFields', 'getSynologyUsername', 'setSynologyDid', 'setSynologySettings', 'setSynologySid'],
|
|
);
|
|
expect(ownMethods(UserAirtrailRepository)).toEqual(
|
|
['clearAirtrailApiKey', 'getAirtrailConnRow', 'getAirtrailWriteEnabled', 'setAirtrailSettings', 'setAirtrailSettingsWithKey'],
|
|
);
|
|
});
|
|
});
|