@@ -63,14 +63,14 @@ void main() {
|
||||
expect(albums.first.name, 'vacation');
|
||||
});
|
||||
|
||||
test('should generate consistent id from directory name', () async {
|
||||
test('should generate consistent id from directory path', () async {
|
||||
await Directory(p.join(tempDir.path, 'test_album')).create();
|
||||
|
||||
final albums1 = await repository.getAllAlbums();
|
||||
final albums2 = await repository.getAllAlbums();
|
||||
|
||||
expect(albums1.first.id, albums2.first.id);
|
||||
expect(albums1.first.id, 'test_album'.hashCode);
|
||||
expect(albums1.first.id, p.join(tempDir.path, 'test_album').hashCode);
|
||||
});
|
||||
|
||||
test('should set createdAt and updatedAt from directory stat', () async {
|
||||
@@ -135,4 +135,4 @@ void main() {
|
||||
expect(album!.name, 'beta');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ void main() {
|
||||
'should return empty list when album directory does not exist',
|
||||
() async {
|
||||
final photos = await repository.getPhotosByAlbumId(
|
||||
'nonexistent'.hashCode,
|
||||
p.join(tempDir.path, 'nonexistent').hashCode,
|
||||
);
|
||||
expect(photos, isEmpty);
|
||||
},
|
||||
@@ -296,7 +296,7 @@ void main() {
|
||||
_createTestPng(albumDir, 'photo1.png', width: 100, height: 200);
|
||||
_createTestGif(albumDir, 'photo2.gif', width: 150, height: 250);
|
||||
|
||||
final albumId = 'my_album'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'my_album').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 2);
|
||||
@@ -312,7 +312,7 @@ void main() {
|
||||
File(p.join(albumDir.path, 'document.txt')).writeAsString('not an image');
|
||||
File(p.join(albumDir.path, 'readme.md')).writeAsString('# Readme');
|
||||
|
||||
final albumId = 'mixed'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'mixed').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -325,7 +325,7 @@ void main() {
|
||||
).create();
|
||||
_createTestPng(albumDir, 'test.png', width: 640, height: 480);
|
||||
|
||||
final albumId = 'png_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'png_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -340,7 +340,7 @@ void main() {
|
||||
).create();
|
||||
_createTestGif(albumDir, 'test.gif', width: 320, height: 240);
|
||||
|
||||
final albumId = 'gif_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'gif_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -355,7 +355,7 @@ void main() {
|
||||
).create();
|
||||
_createTestBmp(albumDir, 'test.bmp', width: 800, height: 600);
|
||||
|
||||
final albumId = 'bmp_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'bmp_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -370,7 +370,7 @@ void main() {
|
||||
).create();
|
||||
_createTestWebpVp8(albumDir, 'test.webp', width: 1920, height: 1080);
|
||||
|
||||
final albumId = 'webp_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'webp_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -387,7 +387,7 @@ void main() {
|
||||
p.join(albumDir.path, 'clip.mp4'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final albumId = 'video_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'video_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -404,7 +404,7 @@ void main() {
|
||||
p.join(albumDir.path, 'movie.mp4'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final albumId = 'video_album'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'video_album').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.length, 1);
|
||||
@@ -417,7 +417,7 @@ void main() {
|
||||
).create();
|
||||
_createTestPng(albumDir, 'test.png', width: 100, height: 100);
|
||||
|
||||
final albumId = 'meta_test'.hashCode;
|
||||
final albumId = p.join(tempDir.path, 'meta_test').hashCode;
|
||||
final photos = await repository.getPhotosByAlbumId(albumId);
|
||||
|
||||
expect(photos.first.albumId, albumId);
|
||||
@@ -446,7 +446,7 @@ void main() {
|
||||
_createTestPng(albumDir, 'unique.png', width: 50, height: 50);
|
||||
|
||||
final allPhotos = await repository.getPhotosByAlbumId(
|
||||
'find_album'.hashCode,
|
||||
p.join(tempDir.path, 'find_album').hashCode,
|
||||
);
|
||||
final targetId = allPhotos.first.id;
|
||||
|
||||
@@ -465,7 +465,7 @@ void main() {
|
||||
_createTestBmp(albumDir, 'dims.bmp', width: 1024, height: 768);
|
||||
|
||||
final allPhotos = await repository.getPhotosByAlbumId(
|
||||
'dims_album'.hashCode,
|
||||
p.join(tempDir.path, 'dims_album').hashCode,
|
||||
);
|
||||
final targetId = allPhotos.first.id;
|
||||
|
||||
@@ -485,7 +485,7 @@ void main() {
|
||||
File(p.join(albumDir.path, 'test.jpg')).writeAsBytesSync([0xFF, 0xD8]);
|
||||
File(p.join(albumDir.path, 'test2.jpeg')).writeAsBytesSync([0xFF, 0xD8]);
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_jpg'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_jpg').hashCode);
|
||||
expect(photos.length, 2);
|
||||
expect(photos.every((p) => p.mimeType == 'image/jpeg'), isTrue);
|
||||
});
|
||||
@@ -498,7 +498,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.png'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_png'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_png').hashCode);
|
||||
expect(photos.first.mimeType, 'image/png');
|
||||
});
|
||||
|
||||
@@ -510,7 +510,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.webp'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_webp'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_webp').hashCode);
|
||||
expect(photos.first.mimeType, 'image/webp');
|
||||
});
|
||||
|
||||
@@ -522,7 +522,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.mp4'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_mp4'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mp4').hashCode);
|
||||
expect(photos.first.mimeType, 'video/mp4');
|
||||
});
|
||||
|
||||
@@ -534,7 +534,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.avi'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_avi'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_avi').hashCode);
|
||||
expect(photos.first.mimeType, 'video/avi');
|
||||
});
|
||||
|
||||
@@ -546,7 +546,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.mov'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_mov'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mov').hashCode);
|
||||
expect(photos.first.mimeType, 'video/quicktime');
|
||||
});
|
||||
|
||||
@@ -558,7 +558,7 @@ void main() {
|
||||
p.join(albumDir.path, 'test.mkv'),
|
||||
).writeAsBytesSync(List.filled(100, 0));
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('mime_mkv'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'mime_mkv').hashCode);
|
||||
expect(photos.first.mimeType, 'video/x-matroska');
|
||||
});
|
||||
});
|
||||
@@ -576,7 +576,7 @@ void main() {
|
||||
).writeAsBytesSync(List.filled(10, 0));
|
||||
}
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('ext_test'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_test').hashCode);
|
||||
expect(photos.length, extensions.length);
|
||||
});
|
||||
|
||||
@@ -592,7 +592,7 @@ void main() {
|
||||
).writeAsBytesSync(List.filled(10, 0));
|
||||
}
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('ext_video'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_video').hashCode);
|
||||
expect(photos.length, extensions.length);
|
||||
});
|
||||
|
||||
@@ -605,9 +605,9 @@ void main() {
|
||||
File(p.join(albumDir.path, 'skip.pdf')).writeAsBytesSync([]);
|
||||
File(p.join(albumDir.path, 'skip.exe')).writeAsBytesSync([]);
|
||||
|
||||
final photos = await repository.getPhotosByAlbumId('ext_ignore'.hashCode);
|
||||
final photos = await repository.getPhotosByAlbumId(p.join(tempDir.path, 'ext_ignore').hashCode);
|
||||
expect(photos.length, 1);
|
||||
expect(photos.first.fileName, 'valid.png');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user