From e0f35500031014a85b71f97a3ce915a50a915731 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Fri, 25 Feb 2022 21:58:20 +0100 Subject: [PATCH 1/4] updated tests and dependencies --- lib/src/models/global_parser.dart | 2 +- pubspec.yaml | 3 ++- test/parser/custom_parser_test.dart | 16 ++++++-------- test/parser/github_parser_test.dart | 10 +++++---- test/parser/gitlab_parser_test.dart | 23 +++++++-------------- test/parser/linkedin_parser_test.dart | 10 +++++---- test/parser/medium_parser_test.dart | 16 +++++++------- test/parser/stack_overflow_parser_test.dart | 14 +++++++------ test/parser/twitter_parser_test.dart | 10 +++++---- 9 files changed, 51 insertions(+), 53 deletions(-) diff --git a/lib/src/models/global_parser.dart b/lib/src/models/global_parser.dart index d39166a..e8e100f 100644 --- a/lib/src/models/global_parser.dart +++ b/lib/src/models/global_parser.dart @@ -1,4 +1,4 @@ -import 'package:collection/collection.dart'; +import 'package:collection/collection.dart' show IterableExtension; import 'url_parser/url_parser.dart'; class GlobalParser { diff --git a/pubspec.yaml b/pubspec.yaml index b9a5b8c..7fc4411 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,13 +1,14 @@ name: fl_business_card_core description: Open-source & serverless Business Card generator, core in Dart for both Mobile & Web implementations. -version: 0.0.1 +version: 0.1.0 homepage: https://github.com/Floating-Dartists/fl_business_card_core environment: sdk: ">=2.16.1 <3.0.0" dependencies: + collection: ^1.15.0 equatable: ^2.0.3 meta: ^1.7.0 diff --git a/test/parser/custom_parser_test.dart b/test/parser/custom_parser_test.dart index 049dab1..908a653 100644 --- a/test/parser/custom_parser_test.dart +++ b/test/parser/custom_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('CustomParser', () { + const parser = CustomParser(); + const tValidUrl = 'https://twitter.com/ABC38_'; const tInvalidUrl = 'htt.fsdfps://twittercom/status/ABC38_'; @@ -11,23 +13,17 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const CustomParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('An invalid URL should throw a ParseException', () { - expect( - const CustomParser().isValid(tInvalidUrl), - false, - ); + expect(parser.isValid(tInvalidUrl), false); }); }); group('recoverUser', () { test('A valid custom URL should return the URL, minus the scheme', () { - expect( - const CustomParser().recoverUser(tValidUrl), - tvalidUsername, - ); + expect(parser.recoverUser(tValidUrl), tvalidUsername); }); }); @@ -36,7 +32,7 @@ void main() { 'A valid custom URL "username" should return the URL, with the sceme', () { expect( - const CustomParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), "https://twitter.com/ABC38_", ); }); diff --git a/test/parser/github_parser_test.dart b/test/parser/github_parser_test.dart index 3de47ec..f2f2e97 100644 --- a/test/parser/github_parser_test.dart +++ b/test/parser/github_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('GithubParser', () { + const parser = GithubParser(); + const tValidUrl = 'https://github.com/ABC38_'; const tInvalidUrl = 'https://githubcom/status/ABC38_'; @@ -11,12 +13,12 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const GithubParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('An invalid URL should throw a ParseException', () { expect( - const GithubParser().isValid(tInvalidUrl), + parser.isValid(tInvalidUrl), false, ); }); @@ -25,7 +27,7 @@ void main() { group('recoverUser', () { test('A valid Github Url should return the user', () { expect( - const GithubParser().recoverUser(tValidUrl), + parser.recoverUser(tValidUrl), tvalidUsername, ); }); @@ -34,7 +36,7 @@ void main() { group('recreateUri', () { test('A valid Github username should return the tValidUrl', () { expect( - const GithubParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), tValidUrl, ); }); diff --git a/test/parser/gitlab_parser_test.dart b/test/parser/gitlab_parser_test.dart index d4689a3..00d474d 100644 --- a/test/parser/gitlab_parser_test.dart +++ b/test/parser/gitlab_parser_test.dart @@ -1,10 +1,11 @@ import 'package:fl_business_card_core/fl_business_card_core.dart' show GitlabParser; -import 'package:fl_business_card_core/src/models/url_parse_exceptions.dart'; import 'package:test/test.dart'; void main() { group('GitlabParser', () { + const parser = GitlabParser(); + const tValidUrl = 'https://gitlab.com/ABC38_'; const tInvalidUrl = 'https://gitlabcom/status/ABC38_'; @@ -12,33 +13,23 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const GitlabParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); - test('An invalid URL should throw a ParseException', () { - expect( - () => const GitlabParser().isValid(tInvalidUrl), - // const CustomParser().isValid(Uri.parse(tInvalidUrl)), - throwsA(isA()), - ); + test('An invalid URL should return false', () { + expect(parser.isValid(tInvalidUrl), false); }); }); group('recoverUser', () { test('A valid Gitlab Url should return the user', () { - expect( - const GitlabParser().recoverUser(tValidUrl), - tvalidUsername, - ); + expect(parser.recoverUser(tValidUrl), tvalidUsername); }); }); group('recreateUri', () { test('A valid Gitlab username should return the tValidUrl', () { - expect( - const GitlabParser().recreateUri(tvalidUsername), - tValidUrl, - ); + expect(parser.recreateUri(tvalidUsername), tValidUrl); }); }); }); diff --git a/test/parser/linkedin_parser_test.dart b/test/parser/linkedin_parser_test.dart index d2cadc6..44e5292 100644 --- a/test/parser/linkedin_parser_test.dart +++ b/test/parser/linkedin_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('LinkedInParser', () { + const parser = LinkedInParser(); + const tValidUrl = 'https://linkedin.com/in/ABC38_'; const tInvalidUrl = 'https://linkedincom/ABC38_'; @@ -11,12 +13,12 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const LinkedInParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('An invalid URL should throw a ParseException', () { expect( - const LinkedInParser().isValid(tInvalidUrl), + parser.isValid(tInvalidUrl), false, ); }); @@ -25,7 +27,7 @@ void main() { group('recoverUser', () { test('A valid LinkedIn Url should return the user', () { expect( - const LinkedInParser().recoverUser(tValidUrl), + parser.recoverUser(tValidUrl), tvalidUsername, ); }); @@ -34,7 +36,7 @@ void main() { group('recreateUri', () { test('A valid LinkedIn username should return the tValidUrl', () { expect( - const LinkedInParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), tValidUrl, ); }); diff --git a/test/parser/medium_parser_test.dart b/test/parser/medium_parser_test.dart index bc1cf08..9f76183 100644 --- a/test/parser/medium_parser_test.dart +++ b/test/parser/medium_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('MediumParser', () { + const parser = MediumParser(); + const tValidUrl = 'https://rouxguillaume.medium.com/'; const tValidUrl2 = 'https://medium.com/@rouxguillaume'; const tInvalidUrl = 'https://rouxguillaume.medium.com/@rouxguillaume/truc'; @@ -12,16 +14,16 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const MediumParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('A valid URL should return true', () { - expect(const MediumParser().isValid(tValidUrl2), true); + expect(parser.isValid(tValidUrl2), true); }); test('An invalid URL should throw a ParseException', () { expect( - const MediumParser().isValid(tInvalidUrl), + parser.isValid(tInvalidUrl), false, ); }); @@ -30,14 +32,14 @@ void main() { group('recoverUser', () { test('A valid Medium Url should return the user', () { expect( - const MediumParser().recoverUser(tValidUrl), + parser.recoverUser(tValidUrl), tvalidUsername, ); }); test('A valid Medium Url should return the user', () { expect( - const MediumParser().recoverUser(tValidUrl2), + parser.recoverUser(tValidUrl2), tvalidUsername2, ); }); @@ -46,14 +48,14 @@ void main() { group('recreateUri', () { test('A valid Medium username should return the tValidUrl', () { expect( - const MediumParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), tValidUrl2, ); }); test('A valid Medium username should return the tValidUrl', () { expect( - const MediumParser().recreateUri(tvalidUsername2), + parser.recreateUri(tvalidUsername2), tValidUrl2, ); }); diff --git a/test/parser/stack_overflow_parser_test.dart b/test/parser/stack_overflow_parser_test.dart index 1be74b4..de8b5de 100644 --- a/test/parser/stack_overflow_parser_test.dart +++ b/test/parser/stack_overflow_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('StackOverflowParser', () { + const parser = StackOverflowParser(); + const tValidUrl = 'https://stackoverflow.com/users/13923049/me%c3%af-m'; const tValidUrl2 = 'https://stackoverflow.com/users/13923049'; const tInvalidUrl = 'https://stackoverflow.com/13923049'; @@ -11,19 +13,19 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const StackOverflowParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('A valid URL should return true', () { expect( - const StackOverflowParser().isValid(tValidUrl2), + parser.isValid(tValidUrl2), true, ); }); test('An invalid URL should throw a ParseException', () { expect( - const StackOverflowParser().isValid(tInvalidUrl), + parser.isValid(tInvalidUrl), false, ); }); @@ -32,14 +34,14 @@ void main() { group('recoverUser', () { test('A valid StackOverflow Url should return the user', () { expect( - const StackOverflowParser().recoverUser(tValidUrl), + parser.recoverUser(tValidUrl), tvalidUsername, ); }); test('A valid StackOverflow Url should return the user', () { expect( - const StackOverflowParser().recoverUser(tValidUrl2), + parser.recoverUser(tValidUrl2), tvalidUsername, ); }); @@ -48,7 +50,7 @@ void main() { group('recreateUri', () { test('A valid StackOverflow username should return the tValidUrl', () { expect( - const StackOverflowParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), tValidUrl2, ); }); diff --git a/test/parser/twitter_parser_test.dart b/test/parser/twitter_parser_test.dart index 3acdb31..bd5674d 100644 --- a/test/parser/twitter_parser_test.dart +++ b/test/parser/twitter_parser_test.dart @@ -4,6 +4,8 @@ import 'package:test/test.dart'; void main() { group('TwitterParser', () { + const parser = TwitterParser(); + const tValidUrl = 'https://twitter.com/ABC38_'; const tInvalidUrl = 'https://twittercom/status/ABC38_'; @@ -11,12 +13,12 @@ void main() { group('isValid', () { test('A valid URL should return true', () { - expect(const TwitterParser().isValid(tValidUrl), true); + expect(parser.isValid(tValidUrl), true); }); test('An invalid URL should throw a ParseException', () { expect( - const TwitterParser().isValid(tInvalidUrl), + parser.isValid(tInvalidUrl), false, ); }); @@ -25,7 +27,7 @@ void main() { group('recoverUser', () { test('A valid Twitter Url should return the user', () { expect( - const TwitterParser().recoverUser(tValidUrl), + parser.recoverUser(tValidUrl), tvalidUsername, ); }); @@ -34,7 +36,7 @@ void main() { group('recreateUri', () { test('A valid Twitter username should return the tValidUrl', () { expect( - const TwitterParser().recreateUri(tvalidUsername), + parser.recreateUri(tvalidUsername), tValidUrl, ); }); From d05ec1795ad1ef4e7f7e6813af8c5a1ef514204e Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Fri, 25 Feb 2022 22:02:47 +0100 Subject: [PATCH 2/4] publish coverage on coveralls --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 87cfe13..3f0efd8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: run: dart test --coverage="coverage" # - name: Exclude generated files from coverage # run: dart pub run remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' - # - name: Collect and report coverage - # uses: coverallsapp/github-action@v1.1.2 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + - name: Collect and report coverage + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 9b1b4be47e2ddffa2c61c58582dde13496d2b838 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Fri, 25 Feb 2022 22:10:52 +0100 Subject: [PATCH 3/4] fixed CI --- .github/workflows/tests.yml | 2 ++ pubspec.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f0efd8..f8fa3eb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,8 @@ jobs: run: dart test --coverage="coverage" # - name: Exclude generated files from coverage # run: dart pub run remove_from_coverage -f coverage/lcov.info -r '\.g\.dart$' + - name: Generate Lcov + run: dart pub run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib - name: Collect and report coverage uses: coverallsapp/github-action@v1.1.2 with: diff --git a/pubspec.yaml b/pubspec.yaml index 7fc4411..1fe0dbd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: meta: ^1.7.0 dev_dependencies: + coverage: ^1.1.0 lint: ^1.8.2 mockito: ^5.1.0 remove_from_coverage: ^2.0.0 From e3955f30619d3c6395e012fa608addcd3f9f43f8 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Fri, 25 Feb 2022 22:12:36 +0100 Subject: [PATCH 4/4] added status badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 22b6426..f2fb116 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # fl_business_card_core +[![Test workflow](https://github.com/Floating-Dartists/fl_business_card_core/actions/workflows/tests.yml/badge.svg)](https://github.com/Floating-Dartists/fl_business_card_core/actions/workflows/tests.yml) + Open-source & serverless Business Card generator, core in Dart for both Mobile & Web implementations. \ No newline at end of file