This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Rui Miguel Alonso <[email protected]> Co-authored-by: Erick <[email protected]>
- Loading branch information
1 parent
ca84b50
commit 999b762
Showing
11 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// ignore_for_file: prefer_const_constructors | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See https://www.dartlang.org/guides/libraries/private-files | ||
|
||
# Files and directories created by pub | ||
.dart_tool/ | ||
.packages | ||
build/ | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Questions Repository | ||
|
||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] | ||
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) | ||
[![License: MIT][license_badge]][license_link] | ||
|
||
Repository to access QuestionsResource through the Api Client. | ||
|
||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license_link]: https://opensource.org/licenses/MIT | ||
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg | ||
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:very_good_analysis/analysis_options.5.1.0.yaml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// Repository to access QuestionsResource from the Api Client. | ||
library questions_repository; | ||
|
||
export 'src/questions_repository.dart'; |
16 changes: 16 additions & 0 deletions
16
packages/questions_repository/lib/src/questions_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:api_client/api_client.dart'; | ||
|
||
/// {@template questions_repository} | ||
/// Repository to access QuestionsResource from the Api Client. | ||
/// {@endtemplate} | ||
class QuestionsRepository { | ||
/// {@macro questions_repository} | ||
const QuestionsRepository(this._questionsResource); | ||
|
||
final QuestionsResource _questionsResource; | ||
|
||
/// Returns [VertexResponse] based on a query. | ||
Future<VertexResponse> getVertexResponse(String query) async { | ||
return _questionsResource.getVertexResponse(query); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: questions_repository | ||
description: Repository to access QuestionsResource through the Api Client. | ||
version: 0.1.0+1 | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ">=3.1.0 <4.0.0" | ||
|
||
dependencies: | ||
api_client: | ||
path: ../api_client | ||
|
||
dev_dependencies: | ||
mocktail: ^1.0.0 | ||
test: ^1.19.2 | ||
very_good_analysis: ^5.1.0 |
35 changes: 35 additions & 0 deletions
35
packages/questions_repository/test/src/questions_repository_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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', () { | ||
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>()), | ||
); | ||
}); | ||
}); | ||
}); | ||
} |