feat(apps): add core API infrastructure

This commit is contained in:
qzl
2026-02-25 14:36:03 +08:00
parent 53c72e48e6
commit 75f4d2c3fb
6 changed files with 236 additions and 0 deletions
@@ -0,0 +1,24 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/core/api/api_exception.dart';
void main() {
group('ApiException', () {
test('creates from DioException with 400 status', () {
final dioException = Exception('Bad request');
final apiException = ApiException.fromDioError(dioException);
expect(apiException, isA<ApiException>());
expect(apiException.message, contains('Request failed'));
});
test('NetworkException has correct message', () {
const exception = NetworkException('No internet');
expect(exception.message, 'No internet');
});
test('UnauthorizedException has default message', () {
const exception = UnauthorizedException();
expect(exception.message, 'Authentication required');
});
});
}