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

Commit

Permalink
feat: questions repository (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Rui Miguel Alonso <[email protected]>
Co-authored-by: Erick <[email protected]>
  • Loading branch information
3 people authored Nov 23, 2023
1 parent ca84b50 commit 999b762
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 3 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
2 changes: 0 additions & 2 deletions packages/api_client/test/src/api_client_test.dart
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';

Expand Down
1 change: 0 additions & 1 deletion packages/app_ui/test/src/widgets/animated_sprite_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: prefer_const_constructors
import 'dart:ui' as ui show Image;

import 'package:app_ui/app_ui.dart';
Expand Down
7 changes: 7 additions & 0 deletions packages/questions_repository/.gitignore
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
12 changes: 12 additions & 0 deletions packages/questions_repository/README.md
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
1 change: 1 addition & 0 deletions packages/questions_repository/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:very_good_analysis/analysis_options.5.1.0.yaml
20 changes: 20 additions & 0 deletions packages/questions_repository/coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/questions_repository/lib/questions_repository.dart
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 packages/questions_repository/lib/src/questions_repository.dart
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);
}
}
16 changes: 16 additions & 0 deletions packages/questions_repository/pubspec.yaml
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
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>()),
);
});
});
});
}

0 comments on commit 999b762

Please sign in to comment.