Skip to content

Commit b4b92a4

Browse files
authored
Drop usage of waitFor (dart-archive/pubspec_parse#114)
1 parent 83007be commit b4b92a4

File tree

3 files changed

+81
-81
lines changed

3 files changed

+81
-81
lines changed

pkgs/pubspec_parse/test/dependency_test.dart

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ line 5, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos
7070
}
7171

7272
void _hostedDependency() {
73-
test('null', () {
74-
final dep = _dependency<HostedDependency>(null);
73+
test('null', () async {
74+
final dep = await _dependency<HostedDependency>(null);
7575
expect(dep.version.toString(), 'any');
7676
expect(dep.hosted, isNull);
7777
expect(dep.toString(), 'HostedDependency: any');
7878
});
7979

80-
test('empty map', () {
81-
final dep = _dependency<HostedDependency>({});
80+
test('empty map', () async {
81+
final dep = await _dependency<HostedDependency>({});
8282
expect(dep.hosted, isNull);
8383
expect(dep.toString(), 'HostedDependency: any');
8484
});
8585

86-
test('string version', () {
87-
final dep = _dependency<HostedDependency>('^1.0.0');
86+
test('string version', () async {
87+
final dep = await _dependency<HostedDependency>('^1.0.0');
8888
expect(dep.version.toString(), '^1.0.0');
8989
expect(dep.hosted, isNull);
9090
expect(dep.toString(), 'HostedDependency: ^1.0.0');
@@ -102,15 +102,15 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v
102102
);
103103
});
104104

105-
test('map w/ just version', () {
106-
final dep = _dependency<HostedDependency>({'version': '^1.0.0'});
105+
test('map w/ just version', () async {
106+
final dep = await _dependency<HostedDependency>({'version': '^1.0.0'});
107107
expect(dep.version.toString(), '^1.0.0');
108108
expect(dep.hosted, isNull);
109109
expect(dep.toString(), 'HostedDependency: ^1.0.0');
110110
});
111111

112-
test('map w/ version and hosted as Map', () {
113-
final dep = _dependency<HostedDependency>({
112+
test('map w/ version and hosted as Map', () async {
113+
final dep = await _dependency<HostedDependency>({
114114
'version': '^1.0.0',
115115
'hosted': {'name': 'hosted_name', 'url': 'https://hosted_url'},
116116
});
@@ -120,8 +120,8 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v
120120
expect(dep.toString(), 'HostedDependency: ^1.0.0');
121121
});
122122

123-
test('map /w hosted as a map without name', () {
124-
final dep = _dependency<HostedDependency>(
123+
test('map /w hosted as a map without name', () async {
124+
final dep = await _dependency<HostedDependency>(
125125
{
126126
'version': '^1.0.0',
127127
'hosted': {'url': 'https://hosted_url'},
@@ -166,8 +166,8 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git
166166
);
167167
});
168168

169-
test('map w/ version and hosted as String', () {
170-
final dep = _dependency<HostedDependency>(
169+
test('map w/ version and hosted as String', () async {
170+
final dep = await _dependency<HostedDependency>(
171171
{'version': '^1.0.0', 'hosted': 'hosted_url'},
172172
skipTryPub: true, // todo: Unskip once put supports this
173173
);
@@ -178,8 +178,8 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git
178178
expect(dep.toString(), 'HostedDependency: ^1.0.0');
179179
});
180180

181-
test('map w/ hosted as String', () {
182-
final dep = _dependency<HostedDependency>({'hosted': 'hosted_url'});
181+
test('map w/ hosted as String', () async {
182+
final dep = await _dependency<HostedDependency>({'hosted': 'hosted_url'});
183183
expect(dep.version, VersionConstraint.any);
184184
expect(dep.hosted!.declaredName, isNull);
185185
expect(dep.hosted!.name, 'dep');
@@ -199,24 +199,24 @@ line 5, column 4: These keys had `null` values, which is not allowed: [hosted]
199199
);
200200
});
201201

202-
test('map w/ null version is fine', () {
203-
final dep = _dependency<HostedDependency>({'version': null});
202+
test('map w/ null version is fine', () async {
203+
final dep = await _dependency<HostedDependency>({'version': null});
204204
expect(dep.version, VersionConstraint.any);
205205
expect(dep.hosted, isNull);
206206
expect(dep.toString(), 'HostedDependency: any');
207207
});
208208
}
209209

210210
void _sdkDependency() {
211-
test('without version', () {
212-
final dep = _dependency<SdkDependency>({'sdk': 'flutter'});
211+
test('without version', () async {
212+
final dep = await _dependency<SdkDependency>({'sdk': 'flutter'});
213213
expect(dep.sdk, 'flutter');
214214
expect(dep.version, VersionConstraint.any);
215215
expect(dep.toString(), 'SdkDependency: flutter');
216216
});
217217

218-
test('with version', () {
219-
final dep = _dependency<SdkDependency>(
218+
test('with version', () async {
219+
final dep = await _dependency<SdkDependency>(
220220
{'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'},
221221
);
222222
expect(dep.sdk, 'flutter');
@@ -240,29 +240,30 @@ void _sdkDependency() {
240240
}
241241

242242
void _gitDependency() {
243-
test('string', () {
244-
final dep = _dependency<GitDependency>({'git': 'url'});
243+
test('string', () async {
244+
final dep = await _dependency<GitDependency>({'git': 'url'});
245245
expect(dep.url.toString(), 'url');
246246
expect(dep.path, isNull);
247247
expect(dep.ref, isNull);
248248
expect(dep.toString(), 'GitDependency: url@url');
249249
});
250250

251-
test('string with version key is ignored', () {
251+
test('string with version key is ignored', () async {
252252
// Regression test for https://github.com/dart-lang/pubspec_parse/issues/13
253-
final dep = _dependency<GitDependency>({'git': 'url', 'version': '^1.2.3'});
253+
final dep =
254+
await _dependency<GitDependency>({'git': 'url', 'version': '^1.2.3'});
254255
expect(dep.url.toString(), 'url');
255256
expect(dep.path, isNull);
256257
expect(dep.ref, isNull);
257258
expect(dep.toString(), 'GitDependency: url@url');
258259
});
259260

260-
test('string with user@ URL', () {
261+
test('string with user@ URL', () async {
261262
final skipTryParse = Platform.environment.containsKey('TRAVIS');
262263
if (skipTryParse) {
263264
print('FYI: not validating git@ URI on travis due to failure');
264265
}
265-
final dep = _dependency<GitDependency>(
266+
final dep = await _dependency<GitDependency>(
266267
{'git': 'git@localhost:dep.git'},
267268
skipTryPub: skipTryParse,
268269
);
@@ -284,8 +285,8 @@ line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos
284285
);
285286
});
286287

287-
test('map', () {
288-
final dep = _dependency<GitDependency>({
288+
test('map', () async {
289+
final dep = await _dependency<GitDependency>({
289290
'git': {'url': 'url', 'path': 'path', 'ref': 'ref'},
290291
});
291292
expect(dep.url.toString(), 'url');
@@ -349,15 +350,16 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map.
349350
}
350351

351352
void _pathDependency() {
352-
test('valid', () {
353-
final dep = _dependency<PathDependency>({'path': '../path'});
353+
test('valid', () async {
354+
final dep = await _dependency<PathDependency>({'path': '../path'});
354355
expect(dep.path, '../path');
355356
expect(dep.toString(), 'PathDependency: path@../path');
356357
});
357358

358-
test('valid with version key is ignored', () {
359-
final dep =
360-
_dependency<PathDependency>({'path': '../path', 'version': '^1.2.3'});
359+
test('valid with version key is ignored', () async {
360+
final dep = await _dependency<PathDependency>(
361+
{'path': '../path', 'version': '^1.2.3'},
362+
);
361363
expect(dep.path, '../path');
362364
expect(dep.toString(), 'PathDependency: path@../path');
363365
});
@@ -423,11 +425,11 @@ void _expectThrowsContaining(Object content, String errorText) {
423425
);
424426
}
425427

426-
T _dependency<T extends Dependency>(
428+
Future<T> _dependency<T extends Dependency>(
427429
Object? content, {
428430
bool skipTryPub = false,
429-
}) {
430-
final value = parse(
431+
}) async {
432+
final value = await parse(
431433
{
432434
...defaultPubspec,
433435
'dependencies': {'dep': content},

0 commit comments

Comments
 (0)