From d8a5db48bccee6da0ed0c6344a6de6d13e827016 Mon Sep 17 00:00:00 2001 From: Justin Baumann Date: Thu, 7 Mar 2024 14:06:34 +0100 Subject: [PATCH] fix tests --- lib/src/models/pubspec_extensions.dart | 9 ++++----- pubspec.yaml | 1 - test/pubspec_extensions_test.dart | 15 ++++----------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/src/models/pubspec_extensions.dart b/lib/src/models/pubspec_extensions.dart index 285270b..d9f77a1 100644 --- a/lib/src/models/pubspec_extensions.dart +++ b/lib/src/models/pubspec_extensions.dart @@ -1,5 +1,4 @@ import 'package:pubspec/pubspec.dart'; -import 'package:yaml/yaml.dart'; /// {@template pubspec_extensions} /// Extensions on [PubSpec] to provide additional functionality. @@ -15,11 +14,11 @@ extension PubspecExtensions on PubSpec { String? issueTracker() => unParsedYaml?['issue_tracker']; /// Optional. List of URLs where users can sponsor development of the package. - YamlList? funding() => unParsedYaml?['funding']; + List? funding() => unParsedYaml?['funding']; /// Optional. Specify files to ignore when conducting a pre-publishing search /// for potential leaks of secrets. - YamlList? falseSecrets() => unParsedYaml?['false_secrets']; + List? falseSecrets() => unParsedYaml?['false_secrets']; /// Optional. Specify a list of screenshot files to display on pub.dev List? screenshots() { @@ -35,10 +34,10 @@ extension PubspecExtensions on PubSpec { } /// Optional field to list the topics that this packages belongs to. - YamlList? topics() => unParsedYaml?['topics']; + List? topics() => unParsedYaml?['topics']; /// Optional. List of ignored security advisories. - YamlList? ignoredAdvisories() => unParsedYaml?['ignored_advisories']; + List? ignoredAdvisories() => unParsedYaml?['ignored_advisories']; } /// {@template screenshot} diff --git a/pubspec.yaml b/pubspec.yaml index 1141b22..04a5132 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,6 @@ dependencies: oauth2: ^2.0.2 path: ^1.8.3 pubspec: ^2.3.0 - yaml: ^3.1.2 dev_dependencies: build_runner: ^2.4.6 diff --git a/test/pubspec_extensions_test.dart b/test/pubspec_extensions_test.dart index 8aa77d0..74768b3 100644 --- a/test/pubspec_extensions_test.dart +++ b/test/pubspec_extensions_test.dart @@ -1,32 +1,27 @@ import 'package:pub_api_client/pub_api_client.dart'; import 'package:pubspec/pubspec.dart'; import 'package:test/test.dart'; -import 'package:yaml/yaml.dart'; void main() { test('Should be able to parse repository field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); expect(pubspec.repository(), 'https://foo.bar/repo'); }); test('Should be able to parse issue tracker field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); expect(pubspec.issueTracker(), 'https://foo.bar/issues'); }); test('Should be able to parse funding field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); final sponsors = pubspec.funding(); - expect(sponsors, isA()); + expect(sponsors, isA()); expect(sponsors, hasLength(2)); expect(sponsors?[0], 'https://foo.bar/sponsor1'); expect(sponsors?[1], 'https://foo.bar/sponsor2'); }); test('Should be able to parse false secrets field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); final falseSecrets = pubspec.falseSecrets(); - expect(falseSecrets, isA()); + expect(falseSecrets, isA()); expect(falseSecrets, hasLength(2)); expect(falseSecrets?[0], '/lib/foo/bar.dart'); expect(falseSecrets?[1], '/lib/bar/foo.dart'); @@ -45,18 +40,16 @@ void main() { }); test('Should be able to parse topics field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); final topics = pubspec.topics(); - expect(topics, isA()); + expect(topics, isA()); expect(topics, hasLength(2)); expect(topics?[0], 'bar'); expect(topics?[1], 'foo'); }); test('Should be able to parse ignoredAdvisories field', () async { - final pubspec = await PubSpec.loadFile('test/example_pubspec.yaml'); final ignoredAdvisories = pubspec.ignoredAdvisories(); - expect(ignoredAdvisories, isA()); + expect(ignoredAdvisories, isA()); expect(ignoredAdvisories, hasLength(2)); expect(ignoredAdvisories?[0], 'foo-bar'); expect(ignoredAdvisories?[1], 'bar-foo');