Skip to content

Commit 47a6560

Browse files
committed
DRY up test copies of pubspec.lock content
1 parent 2169c42 commit 47a6560

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
lines changed

webdev/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: webdev
2-
version: 0.1.3+1
2+
version: 0.1.4-dev
33
author: Dart Team <misc@dartlang.org>
44
homepage: https://github.com/dart-lang/webdev
55
description: >-

webdev/test/integration_test.dart

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,7 @@ A dependency on `build_runner` was not found.'''));
5858
name: sample
5959
''').create();
6060

61-
await d.file('pubspec.lock', '''
62-
# Copy-pasted from a valid run
63-
packages:
64-
build_runner:
65-
dependency: "direct main"
66-
description:
67-
name: build_runner
68-
url: "https://pub.dartlang.org"
69-
source: hosted
70-
version: "$version"
71-
''').create();
61+
await d.file('pubspec.lock', _pubspecLock(version: version)).create();
7262

7363
await d.file('.packages', '''
7464
''').create();
@@ -116,17 +106,7 @@ name: sample
116106
name: sample
117107
''').create();
118108

119-
await d.file('pubspec.lock', '''
120-
# Copy-pasted from a valid run
121-
packages:
122-
build_runner:
123-
dependency: "direct main"
124-
description:
125-
name: build_runner
126-
url: "https://pub.dartlang.org"
127-
source: hosted
128-
version: "0.8.0"
129-
''').create();
109+
await d.file('pubspec.lock', _pubspecLock()).create();
130110

131111
var process = await _runWebDev(['build'], workingDirectory: d.sandbox);
132112

@@ -143,17 +123,7 @@ packages:
143123
name: sample
144124
''').create();
145125

146-
await d.file('pubspec.lock', '''
147-
# Copy-pasted from a valid run
148-
packages:
149-
build_runner:
150-
dependency: "direct main"
151-
description:
152-
name: build_runner
153-
url: "https://pub.dartlang.org"
154-
source: hosted
155-
version: "0.8.0"
156-
''').create();
126+
await d.file('pubspec.lock', _pubspecLock()).create();
157127

158128
await d.file('.packages', '').create();
159129

@@ -169,17 +139,7 @@ packages:
169139
});
170140

171141
test('should fail if there has been a dependency change', () async {
172-
await d.file('pubspec.lock', '''
173-
# Copy-pasted from a valid run
174-
packages:
175-
build_runner:
176-
dependency: "direct main"
177-
description:
178-
name: build_runner
179-
url: "https://pub.dartlang.org"
180-
source: hosted
181-
version: "0.8.0"
182-
''').create();
142+
await d.file('pubspec.lock', _pubspecLock()).create();
183143

184144
await d.file('.packages', '').create();
185145

@@ -228,6 +188,18 @@ dependencies:
228188
}, timeout: const Timeout(const Duration(minutes: 5)));
229189
}
230190

191+
String _pubspecLock({String version: '0.8.0'}) => '''
192+
# Copy-pasted from a valid run
193+
packages:
194+
build_runner:
195+
dependency: "direct main"
196+
description:
197+
name: build_runner
198+
url: "https://pub.dartlang.org"
199+
source: hosted
200+
version: "$version"
201+
''';
202+
231203
/// Returns an environment map that includes `PUB_ENVIRONMENT`.
232204
///
233205
/// Maintains any existing values for this environment var.

0 commit comments

Comments
 (0)