test(logging): optimize logging tests and fix broken tests

This commit is contained in:
qzl
2026-04-01 14:46:47 +08:00
parent d1092df254
commit 640b4d15a3
6 changed files with 316 additions and 87 deletions
@@ -22,7 +22,11 @@ class _FakeApiClient implements IApiClient {
void setPatch(String path, dynamic data) => _patchResponses[path] = data;
@override
Future<Response<T>> get<T>(String path, {Options? options}) async {
Future<Response<T>> get<T>(
String path, {
Map<String, String>? queryParameters,
Options? options,
}) async {
if (!_getResponses.containsKey(path)) {
throw StateError('missing GET mock for $path');
}
@@ -33,7 +37,11 @@ class _FakeApiClient implements IApiClient {
}
@override
Future<Response<T>> post<T>(String path, {data, Options? options}) async {
Future<Response<T>> post<T>(
String path, {
dynamic data,
Options? options,
}) async {
if (!_postResponses.containsKey(path)) {
throw StateError('missing POST mock for $path');
}
@@ -44,7 +52,11 @@ class _FakeApiClient implements IApiClient {
}
@override
Future<Response<T>> patch<T>(String path, {data, Options? options}) async {
Future<Response<T>> patch<T>(
String path, {
dynamic data,
Options? options,
}) async {
if (!_patchResponses.containsKey(path)) {
throw StateError('missing PATCH mock for $path');
}
@@ -55,7 +67,7 @@ class _FakeApiClient implements IApiClient {
}
@override
Future<Response<T>> delete<T>(String path, {data, Options? options}) {
Future<Response<T>> delete<T>(String path, {dynamic data, Options? options}) {
throw UnimplementedError();
}
@@ -68,7 +80,7 @@ class _FakeApiClient implements IApiClient {
}
@override
Future<Response<T>> put<T>(String path, {data, Options? options}) {
Future<Response<T>> put<T>(String path, {dynamic data, Options? options}) {
throw UnimplementedError();
}
}
@@ -111,7 +123,7 @@ void main() {
'id': 'f1',
'sender': {'id': 'u1', 'username': 'alice', 'avatar_url': null},
'recipient': {'id': 'u2', 'username': 'bob', 'avatar_url': null},
'content': 'hi',
'content': {'message': 'hi'},
'status': 'accepted',
'created_at': '2026-03-27T08:00:00Z',
});
@@ -137,7 +149,7 @@ void main() {
'id': 'f1',
'sender': {'id': 'u1', 'username': 'alice', 'avatar_url': null},
'recipient': {'id': 'u2', 'username': 'bob', 'avatar_url': null},
'content': 'hi',
'content': {'message': 'hi'},
'status': 'pending',
'created_at': '2026-03-27T08:00:00Z',
});