chore(version): update app version to 1.3.5+85 and improve test coverage reporting in CI

This commit is contained in:
mso7nueh
2025-12-08 11:19:08 +03:00
parent abe4985f0e
commit c2a506cdbf
148 changed files with 12395 additions and 1889 deletions

View File

@@ -7,74 +7,60 @@ import 'package:mockito/mockito.dart';
import 'comments_repository_test.mocks.dart';
@GenerateNiceMocks([MockSpec<CommentsService>()])
@GenerateMocks([CommentsService])
void main() {
group('CommentsRepository', () {
late CommentsRepository commentsRepository;
late MockCommentsService mockCommentsService;
late MockCommentsService mockService;
late CommentsRepository repository;
setUp(() {
mockCommentsService = MockCommentsService();
commentsRepository = CommentsRepository(service: mockCommentsService);
mockService = MockCommentsService();
repository = CommentsRepository(service: mockService);
});
test('deleteComment - успешное удаление комментария', () async {
const commentId = 1;
test('deleteComment calls service.deleteComment', () async {
const id = 1;
when(mockCommentsService.deleteComment(commentId))
when(mockService.deleteComment(id))
.thenAnswer((_) async => Future.value());
await commentsRepository.deleteComment(id: commentId);
await repository.deleteComment(id: id);
verify(mockCommentsService.deleteComment(commentId)).called(1);
verify(mockService.deleteComment(id)).called(1);
});
test('deleteComment - пробрасывает исключение', () async {
const commentId = 1;
test('deleteComment rethrows exception when service throws', () async {
const id = 1;
final exception = Exception('Test error');
when(mockCommentsService.deleteComment(commentId))
.thenThrow(Exception('Ошибка удаления'));
when(mockService.deleteComment(id))
.thenThrow(exception);
expect(
() => commentsRepository.deleteComment(id: commentId),
throwsException,
);
expect(() => repository.deleteComment(id: id), throwsException);
});
test('updateComment - успешное обновление комментария', () async {
const commentId = 1;
const newBody = 'Обновлённый текст комментария';
final updateModel = CommentUpdateModel(body: newBody);
test('updateComment calls service.updateComment with correct model', () async {
const id = 1;
const body = 'Updated comment text';
final updateModel = CommentUpdateModel(body: body);
when(mockCommentsService.updateComment(commentId, updateModel))
when(mockService.updateComment(id, updateModel))
.thenAnswer((_) async => Future.value());
await commentsRepository.updateComment(id: commentId, body: newBody);
await repository.updateComment(id: id, body: body);
verify(mockCommentsService.updateComment(
commentId,
argThat(
predicate<CommentUpdateModel>(
(m) => m.body == newBody,
),
),
)).called(1);
verify(mockService.updateComment(id, updateModel)).called(1);
});
test('updateComment - пробрасывает исключение', () async {
const commentId = 1;
const newBody = 'Обновлённый текст';
test('updateComment rethrows exception when service throws', () async {
const id = 1;
const body = 'Updated comment text';
final exception = Exception('Test error');
when(mockCommentsService.updateComment(
commentId,
any,
)).thenThrow(Exception('Ошибка обновления'));
when(mockService.updateComment(id, any))
.thenThrow(exception);
expect(
() => commentsRepository.updateComment(id: commentId, body: newBody),
throwsException,
);
expect(() => repository.updateComment(id: id, body: body), throwsException);
});
});
}