nostr tools added

This commit is contained in:
gitea
2025-11-06 14:46:59 +01:00
parent d8c90cb105
commit f8aa20eb5c
14 changed files with 1146 additions and 141 deletions
+65 -29
View File
@@ -207,11 +207,28 @@ void main() {
];
final mockDio = _createMockDio(
onGet: (path) => Response(
statusCode: 200,
data: mockAssets,
requestOptions: RequestOptions(path: path),
),
onPost: (path, data) {
if (path == '/api/search/metadata') {
// Return the correct nested response structure
return Response(
statusCode: 200,
data: {
'assets': {
'items': mockAssets,
'total': mockAssets.length,
'count': mockAssets.length,
'nextPage': null,
}
},
requestOptions: RequestOptions(path: path),
);
}
return Response(
statusCode: 200,
data: {},
requestOptions: RequestOptions(path: path),
);
},
);
final immichService = ImmichService(
@@ -238,28 +255,38 @@ void main() {
test('fetchAssets - pagination', () async {
// Arrange
final mockDio = _createMockDio(
onGet: (path) {
// Extract query parameters from request options
// The path might be just the endpoint, so we need to check request options
final uri = path.startsWith('http')
? Uri.parse(path)
: Uri.parse('https://immich.example.com$path');
final queryParams = uri.queryParameters;
final skip = int.parse(queryParams['skip'] ?? '0');
final limit = int.parse(queryParams['limit'] ?? '100');
onPost: (path, data) {
if (path == '/api/search/metadata') {
// Extract limit and skip from request body (data), not query params
final requestData = data as Map<String, dynamic>;
final limit = requestData['limit'] as int? ?? 100;
final skip = requestData['skip'] as int? ?? 0;
return Response(
statusCode: 200,
data: {
'assets': {
'items': List.generate(
limit,
(i) => {
'id': 'asset-${skip + i}',
'originalFileName': 'image${skip + i}.jpg',
'createdAt': DateTime.now().toIso8601String(),
'fileSizeByte': 1000,
'mimeType': 'image/jpeg',
},
),
'total': 100, // Mock total
'count': limit,
'nextPage': null,
}
},
requestOptions: RequestOptions(path: path),
);
}
return Response(
statusCode: 200,
data: List.generate(
limit,
(i) => {
'id': 'asset-${skip + i}',
'originalFileName': 'image${skip + i}.jpg',
'createdAt': DateTime.now().toIso8601String(),
'fileSizeByte': 1000,
'mimeType': 'image/jpeg',
},
),
data: {},
requestOptions: RequestOptions(path: path),
);
},
@@ -287,11 +314,20 @@ void main() {
test('fetchAssets - server error', () async {
// Arrange
final mockDio = _createMockDio(
onGet: (path) => Response(
statusCode: 500,
data: {'error': 'Internal server error'},
requestOptions: RequestOptions(path: path),
),
onPost: (path, data) {
if (path == '/api/search/metadata') {
return Response(
statusCode: 500,
data: {'error': 'Internal server error', 'message': 'Internal server error'},
requestOptions: RequestOptions(path: path),
);
}
return Response(
statusCode: 200,
data: {},
requestOptions: RequestOptions(path: path),
);
},
);
final immichService = ImmichService(