Commit 79d1d3a7 authored by pq's avatar pq

Prefer implict `equals` matcher in test expectations.

@Hixie: as per our conversation, a little more concise.
parent a5eb4c04
...@@ -41,12 +41,12 @@ void main() { ...@@ -41,12 +41,12 @@ void main() {
CreateCommand command = new CreateCommand(); CreateCommand command = new CreateCommand();
CommandRunner runner = createTestCommandRunner(command); CommandRunner runner = createTestCommandRunner(command);
int code = await runner.run(<String>['create', '--no-pub', temp.path]); int code = await runner.run(<String>['create', '--no-pub', temp.path]);
expect(code, equals(0)); expect(code, 0);
expect(count, 0); expect(count, 0);
flutterUsage.enabled = true; flutterUsage.enabled = true;
code = await runner.run(<String>['create', '--no-pub', temp.path]); code = await runner.run(<String>['create', '--no-pub', temp.path]);
expect(code, equals(0)); expect(code, 0);
expect(count, flutterUsage.isFirstRun ? 0 : 2); expect(count, flutterUsage.isFirstRun ? 0 : 2);
count = 0; count = 0;
...@@ -54,7 +54,7 @@ void main() { ...@@ -54,7 +54,7 @@ void main() {
DoctorCommand doctorCommand = new DoctorCommand(); DoctorCommand doctorCommand = new DoctorCommand();
runner = createTestCommandRunner(doctorCommand); runner = createTestCommandRunner(doctorCommand);
code = await runner.run(<String>['doctor']); code = await runner.run(<String>['doctor']);
expect(code, equals(0)); expect(code, 0);
expect(count, 0); expect(count, 0);
}, overrides: <Type, dynamic>{ }, overrides: <Type, dynamic>{
Usage: new Usage() Usage: new Usage()
......
...@@ -38,7 +38,7 @@ void main() { ...@@ -38,7 +38,7 @@ void main() {
return createTestCommandRunner(command).run( return createTestCommandRunner(command).run(
<String>['analyze', '--no-current-package', '--no-current-directory', dartFileA.path, dartFileB.path] <String>['analyze', '--no-current-package', '--no-current-directory', dartFileA.path, dartFileB.path]
).then((int code) { ).then((int code) {
expect(code, equals(1)); expect(code, 1);
expect(testLogger.errorText, '[warning] The imported libraries \'a.dart\' and \'b.dart\' cannot have the same name \'test\' (${dartFileB.path})\n'); expect(testLogger.errorText, '[warning] The imported libraries \'a.dart\' and \'b.dart\' cannot have the same name \'test\' (${dartFileB.path})\n');
expect(testLogger.statusText, 'Analyzing 2 entry points...\n'); expect(testLogger.statusText, 'Analyzing 2 entry points...\n');
}); });
......
...@@ -12,7 +12,7 @@ void main() { ...@@ -12,7 +12,7 @@ void main() {
testUsingContext('stores the requested id', () { testUsingContext('stores the requested id', () {
String deviceId = '1234'; String deviceId = '1234';
AndroidDevice device = new AndroidDevice(deviceId); AndroidDevice device = new AndroidDevice(deviceId);
expect(device.id, equals(deviceId)); expect(device.id, deviceId);
}); });
}); });
......
...@@ -43,10 +43,10 @@ void main() { ...@@ -43,10 +43,10 @@ void main() {
CommandRunner runner = createTestCommandRunner(command); CommandRunner runner = createTestCommandRunner(command);
int code = await runner.run(<String>['create', '--no-pub', temp.path]); int code = await runner.run(<String>['create', '--no-pub', temp.path]);
expect(code, equals(0)); expect(code, 0);
code = await runner.run(<String>['create', '--no-pub', temp.path]); code = await runner.run(<String>['create', '--no-pub', temp.path]);
expect(code, equals(0)); expect(code, 0);
}); });
// Verify that we fail with an error code when the file exists. // Verify that we fail with an error code when the file exists.
...@@ -57,7 +57,7 @@ void main() { ...@@ -57,7 +57,7 @@ void main() {
File existingFile = new File("${temp.path.toString()}/bad"); File existingFile = new File("${temp.path.toString()}/bad");
if (!existingFile.existsSync()) existingFile.createSync(); if (!existingFile.existsSync()) existingFile.createSync();
int code = await runner.run(<String>['create', existingFile.path]); int code = await runner.run(<String>['create', existingFile.path]);
expect(code, equals(1)); expect(code, 1);
}); });
}); });
} }
...@@ -70,7 +70,7 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as ...@@ -70,7 +70,7 @@ Future<Null> _createAndAnalyzeProject(Directory dir, List<String> createArgs) as
args.addAll(createArgs); args.addAll(createArgs);
args.add(dir.path); args.add(dir.path);
int code = await runner.run(args); int code = await runner.run(args);
expect(code, equals(0)); expect(code, 0);
String mainPath = path.join(dir.path, 'lib', 'main.dart'); String mainPath = path.join(dir.path, 'lib', 'main.dart');
expect(new File(mainPath).existsSync(), true); expect(new File(mainPath).existsSync(), true);
......
...@@ -15,14 +15,14 @@ void main() { ...@@ -15,14 +15,14 @@ void main() {
testUsingContext('returns 0 when called', () { testUsingContext('returns 0 when called', () {
DevicesCommand command = new DevicesCommand(); DevicesCommand command = new DevicesCommand();
return createTestCommandRunner(command).run(<String>['list']).then((int code) { return createTestCommandRunner(command).run(<String>['list']).then((int code) {
expect(code, equals(0)); expect(code, 0);
}); });
}); });
testUsingContext('no error when no connected devices', () { testUsingContext('no error when no connected devices', () {
DevicesCommand command = new DevicesCommand(); DevicesCommand command = new DevicesCommand();
return createTestCommandRunner(command).run(<String>['list']).then((int code) { return createTestCommandRunner(command).run(<String>['list']).then((int code) {
expect(code, equals(0)); expect(code, 0);
expect(testLogger.statusText, contains('No connected devices')); expect(testLogger.statusText, contains('No connected devices'));
}); });
}, overrides: <Type, dynamic>{ }, overrides: <Type, dynamic>{
......
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
'--target=/some/app/test/e2e.dart', '--target=/some/app/test/e2e.dart',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(1)); expect(code, 1);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, contains( expect(buffer.errorText, contains(
'Test file not found: /some/app/test_driver/e2e_test.dart' 'Test file not found: /some/app/test_driver/e2e_test.dart'
...@@ -89,7 +89,7 @@ void main() { ...@@ -89,7 +89,7 @@ void main() {
'--target=$testApp', '--target=$testApp',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(1)); expect(code, 1);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, contains( expect(buffer.errorText, contains(
'Application failed to start. Will not run test. Quitting.' 'Application failed to start. Will not run test. Quitting.'
...@@ -107,7 +107,7 @@ void main() { ...@@ -107,7 +107,7 @@ void main() {
'--target=$appFile', '--target=$appFile',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(1)); expect(code, 1);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, contains( expect(buffer.errorText, contains(
'Application file $appFile is outside the package directory $packageDir' 'Application file $appFile is outside the package directory $packageDir'
...@@ -125,7 +125,7 @@ void main() { ...@@ -125,7 +125,7 @@ void main() {
'--target=$appFile', '--target=$appFile',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(1)); expect(code, 1);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, contains( expect(buffer.errorText, contains(
'Application file main.dart must reside in one of the ' 'Application file main.dart must reside in one of the '
...@@ -160,7 +160,7 @@ void main() { ...@@ -160,7 +160,7 @@ void main() {
'--target=$testApp', '--target=$testApp',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(0)); expect(code, 0);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, isEmpty); expect(buffer.errorText, isEmpty);
}); });
...@@ -191,7 +191,7 @@ void main() { ...@@ -191,7 +191,7 @@ void main() {
'--target=$testApp', '--target=$testApp',
]; ];
return createTestCommandRunner(command).run(args).then((int code) { return createTestCommandRunner(command).run(args).then((int code) {
expect(code, equals(123)); expect(code, 123);
BufferLogger buffer = logger; BufferLogger buffer = logger;
expect(buffer.errorText, isEmpty); expect(buffer.errorText, isEmpty);
}); });
......
...@@ -22,7 +22,7 @@ void main() { ...@@ -22,7 +22,7 @@ void main() {
testDeviceManager.addDevice(device); testDeviceManager.addDevice(device);
return createTestCommandRunner(command).run(<String>['install']).then((int code) { return createTestCommandRunner(command).run(<String>['install']).then((int code) {
expect(code, equals(0)); expect(code, 0);
}); });
}); });
...@@ -36,7 +36,7 @@ void main() { ...@@ -36,7 +36,7 @@ void main() {
testDeviceManager.addDevice(device); testDeviceManager.addDevice(device);
return createTestCommandRunner(command).run(<String>['install']).then((int code) { return createTestCommandRunner(command).run(<String>['install']).then((int code) {
expect(code, equals(0)); expect(code, 0);
}); });
}); });
}); });
......
...@@ -15,7 +15,7 @@ void main() { ...@@ -15,7 +15,7 @@ void main() {
ListenCommand command = new ListenCommand(singleRun: true); ListenCommand command = new ListenCommand(singleRun: true);
applyMocksToCommand(command); applyMocksToCommand(command);
return createTestCommandRunner(command).run(<String>['listen']).then((int code) { return createTestCommandRunner(command).run(<String>['listen']).then((int code) {
expect(code, equals(1)); expect(code, 1);
}); });
}); });
}); });
......
...@@ -15,7 +15,7 @@ void main() { ...@@ -15,7 +15,7 @@ void main() {
LogsCommand command = new LogsCommand(); LogsCommand command = new LogsCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
return createTestCommandRunner(command).run(<String>['-d', 'abc123', 'logs']).then((int code) { return createTestCommandRunner(command).run(<String>['-d', 'abc123', 'logs']).then((int code) {
expect(code, equals(1)); expect(code, 1);
}); });
}); });
}); });
......
...@@ -15,7 +15,7 @@ void main() { ...@@ -15,7 +15,7 @@ void main() {
RunCommand command = new RunCommand(); RunCommand command = new RunCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
return createTestCommandRunner(command).run(<String>['run', '-t', 'abc123']).then((int code) { return createTestCommandRunner(command).run(<String>['run', '-t', 'abc123']).then((int code) {
expect(code, equals(1)); expect(code, 1);
}); });
}); });
}); });
......
...@@ -21,7 +21,7 @@ void main() { ...@@ -21,7 +21,7 @@ void main() {
when(device.stopApp(any)).thenReturn(new Future<bool>.value(true)); when(device.stopApp(any)).thenReturn(new Future<bool>.value(true));
testDeviceManager.addDevice(device); testDeviceManager.addDevice(device);
return createTestCommandRunner(command).run(<String>['stop']).then((int code) { return createTestCommandRunner(command).run(<String>['stop']).then((int code) {
expect(code, equals(0)); expect(code, 0);
}); });
}); });
...@@ -33,7 +33,7 @@ void main() { ...@@ -33,7 +33,7 @@ void main() {
testDeviceManager.addDevice(device); testDeviceManager.addDevice(device);
return createTestCommandRunner(command).run(<String>['stop']).then((int code) { return createTestCommandRunner(command).run(<String>['stop']).then((int code) {
expect(code, equals(0)); expect(code, 0);
}); });
}); });
}); });
......
...@@ -15,7 +15,7 @@ void main() { ...@@ -15,7 +15,7 @@ void main() {
TraceCommand command = new TraceCommand(); TraceCommand command = new TraceCommand();
applyMocksToCommand(command); applyMocksToCommand(command);
return createTestCommandRunner(command).run(<String>['trace']).then((int code) { return createTestCommandRunner(command).run(<String>['trace']).then((int code) {
expect(code, equals(1)); expect(code, 1);
}); });
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment