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

feat: questions repository #12

Merged
merged 19 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion packages/app_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dependencies:

dev_dependencies:
build_runner: ^2.4.6
flutter_gen_runner: ^5.3.2
flutter_test:
sdk: flutter
flutter_gen_runner: ^5.3.2
mocktail: ^1.0.0
very_good_analysis: ^5.1.0

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 from the Api Client.
omartinma marked this conversation as resolved.
Show resolved Hide resolved

[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 @@
/// A Very Good Project created by Very Good CLI.
omartinma marked this conversation as resolved.
Show resolved Hide resolved
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}
/// A Very Good Project created by Very Good CLI.
omartinma marked this conversation as resolved.
Show resolved Hide resolved
/// {@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);
omartinma marked this conversation as resolved.
Show resolved Hide resolved
}
}
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: A Very Good Project created by Very Good CLI.
omartinma marked this conversation as resolved.
Show resolved Hide resolved
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>()),
);
});
});
});
}