-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0234b
commit fcccb46
Showing
27 changed files
with
791 additions
and
50 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,23 @@ | ||
name: api | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "api/**" | ||
- ".github/workflows/api.yaml" | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1 | ||
with: | ||
dart_sdk: 3.5.0 | ||
coverage_excludes: "**/*.g.dart" | ||
working_directory: api | ||
analyze_directories: "routes test lib" | ||
report_on: "routes" |
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,2 +1,2 @@ | ||
export 'exceptions/exceptions.dart'; | ||
export 'extensions/extensions.dart'; | ||
export 'src/exceptions/exceptions.dart'; | ||
export 'src/extensions/extensions.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
File renamed without changes.
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
14 changes: 0 additions & 14 deletions
14
api/packages/db_client/test/src/models/db_entity_record_test.dart
This file was deleted.
Oops, something went wrong.
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
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
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
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
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,8 @@ | ||
include: package:very_good_analysis/analysis_options.6.0.0.yaml | ||
linter: | ||
rules: | ||
file_names: false | ||
analyzer: | ||
errors: | ||
prefer_const_constructors: ignore | ||
prefer_const_literals_to_create_immutables: ignore |
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,79 @@ | ||
// ignore_for_file: prefer_const_constructors | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:api/api.dart'; | ||
import 'package:dart_frog/dart_frog.dart'; | ||
import 'package:db_client/db_client.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../routes/_middleware.dart'; | ||
|
||
class _MockRequestContext extends Mock implements RequestContext {} | ||
|
||
void main() { | ||
group('middleware', () { | ||
late RequestContext context; | ||
late Request request; | ||
|
||
setUp(() { | ||
context = _MockRequestContext(); | ||
request = Request.get(Uri.parse('http://localhost/')); | ||
|
||
when(() => context.request).thenReturn(request); | ||
when(() => context.provide<Future<DbClient>>(any())).thenReturn(context); | ||
}); | ||
|
||
test('provides a DbClient instance', () async { | ||
final handler = middleware((_) => Response()); | ||
|
||
await handler(context); | ||
|
||
final create = verify( | ||
() => context.provide<Future<DbClient>>(captureAny()), | ||
).captured.single as Future<DbClient> Function(); | ||
|
||
await expectLater( | ||
create(), | ||
completion(isA<DbClient>()), | ||
); | ||
}); | ||
|
||
test( | ||
'returns Response with HttpStatus.notFound when NotFound is thrown', | ||
() async { | ||
final handler = middleware((_) => throw NotFound('Not found')); | ||
|
||
await expectLater( | ||
handler(context), | ||
completion( | ||
isA<Response>().having( | ||
(response) => response.statusCode, | ||
'statusCode', | ||
equals(HttpStatus.notFound), | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
|
||
test( | ||
'returns Response with HttpStatus.badRequest when BadRequest is thrown', | ||
() async { | ||
final handler = middleware((_) => throw BadRequest('Bad request')); | ||
|
||
await expectLater( | ||
handler(context), | ||
completion( | ||
isA<Response>().having( | ||
(response) => response.statusCode, | ||
'statusCode', | ||
equals(HttpStatus.badRequest), | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
}); | ||
} |
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
Oops, something went wrong.