Fix external library path validation #8319 (#8366)

* Fix isImmichPath

* prettier write

* Fis isImmichPath code comment

* Refactor isImmichPath function based on team suggestions

* Test isImmichPath

* fix: clean comments

* Refactor isImmichPath test based on team suggestions

* Clean code with lintern suggestions
This commit is contained in:
Pablo Diz 2024-03-31 16:47:03 +02:00 committed by GitHub
parent 34cbb18ecd
commit 6a4bc777a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,29 @@
import { StorageCore } from 'src/cores/storage.core';
jest.mock('src/constants', () => ({
APP_MEDIA_LOCATION: '/photos',
}));
describe('StorageCore', () => {
describe('isImmichPath', () => {
it('should return true for APP_MEDIA_LOCATION path', () => {
const immichPath = '/photos';
expect(StorageCore.isImmichPath(immichPath)).toBe(true);
});
it('should return true for paths within the APP_MEDIA_LOCATION', () => {
const immichPath = '/photos/new/';
expect(StorageCore.isImmichPath(immichPath)).toBe(true);
});
it('should return false for paths outside the APP_MEDIA_LOCATION and same starts', () => {
const nonImmichPath = '/photos_new';
expect(StorageCore.isImmichPath(nonImmichPath)).toBe(false);
});
it('should return false for paths outside the APP_MEDIA_LOCATION', () => {
const nonImmichPath = '/some/other/path';
expect(StorageCore.isImmichPath(nonImmichPath)).toBe(false);
});
});
});