Skip to content

Commit 727e89d

Browse files
committed
Add a succeeding integration test
1 parent 0f9d353 commit 727e89d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

webdev/test/integration_test.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,44 @@ packages:
153153
process.stdout, emits('An unexpected exception has occurred.'));
154154
await process.shouldExit(70);
155155
});
156+
157+
test('should succeed with valid configuration', () async {
158+
var exampleDirectory = p.absolute(p.join(p.current, '..', 'example'));
159+
var process = await TestProcess.start('pub', ['get'],
160+
workingDirectory: exampleDirectory, environment: _getPubEnvironment());
161+
162+
await process.shouldExit(0);
163+
164+
await d.file('.packages', isNotEmpty).validate(exampleDirectory);
165+
await d.file('pubspec.lock', isNotEmpty).validate(exampleDirectory);
166+
167+
process = await TestProcess.start(
168+
'dart', [_webdevBin, 'build', '-o', d.sandbox],
169+
workingDirectory: exampleDirectory);
170+
171+
var output = await process.stdoutStream().join('\n');
172+
173+
expect(output, contains(d.sandbox));
174+
expect(output, contains('[INFO] Succeeded'));
175+
await process.shouldExit(0);
176+
177+
await d.file('web/main.dart.js', isNotEmpty).validate();
178+
}, timeout: const Timeout(const Duration(minutes: 5)));
179+
}
180+
181+
/// Returns an environment map that includes `PUB_ENVIRONMENT`.
182+
///
183+
/// Maintains any existing values for this environment var.
184+
/// Adds a new value that flags this is a bot/test and not human usage.
185+
Map<String, String> _getPubEnvironment() {
186+
var pubEnvironmentKey = 'PUB_ENVIRONMENT';
187+
var pubEnvironment = Platform.environment[pubEnvironmentKey] ?? '';
188+
if (pubEnvironment.isNotEmpty) {
189+
pubEnvironment = '$pubEnvironment;';
190+
}
191+
pubEnvironment = '${pubEnvironment}bot.pkg.webdev.test';
192+
193+
var environment = {'PUB_ENVIRONMENT': pubEnvironment};
194+
195+
return environment;
156196
}

0 commit comments

Comments
 (0)