Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
test: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
omartinma committed Nov 22, 2023
1 parent 394119e commit 528b3a5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/questions_repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: questions_repository

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
paths:
- "packages/questions_repository/**"
- ".github/workflows/questions_repository.yaml"

pull_request:
paths:
- "packages/questions_repository/**"
- ".github/workflows/questions_repository.yaml"

jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
with:
working_directory: packages/questions_repository
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class QuestionsRepository {

final QuestionsResource _questionsResource;

/// Returns [VertexResponse] based on a query.
Future<VertexResponse> getVertexResponse(String query) async {
return _questionsResource.getVertexResponse(query);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
// ignore_for_file: prefer_const_constructors
import 'package:api_client/api_client.dart';
import 'package:mocktail/mocktail.dart';
import 'package:questions_repository/questions_repository.dart';
import 'package:test/test.dart';

class _MockQuestionsResource extends Mock implements QuestionsResource {}

class _FakeVertexResponse extends Fake implements VertexResponse {}

void main() {
group('QuestionsRepository', () {
test('can be instantiated', () {
expect(QuestionsRepository(), isNotNull);
late QuestionsResource questionsResource;
late QuestionsRepository questionsRepository;

setUp(() {
questionsResource = _MockQuestionsResource();
questionsRepository = QuestionsRepository(questionsResource);
});

setUpAll(() {
registerFallbackValue(_FakeVertexResponse());
});

group('getVertexResponse', () {
test('returns VertexResponse', () {
when(() => questionsResource.getVertexResponse(any()))
.thenAnswer((_) async => _FakeVertexResponse());
expectLater(
questionsRepository.getVertexResponse(''),
completion(isA<VertexResponse>()),
);
});
});
});
}

0 comments on commit 528b3a5

Please sign in to comment.