Commit e6b45c50 authored by Devon Carew's avatar Devon Carew

use mokito in the init tests

parent ab441685
...@@ -65,13 +65,10 @@ Or if the Sky APK is not already on your device, run: ...@@ -65,13 +65,10 @@ Or if the Sky APK is not already on your device, run:
stdout.addStream(process.stdout); stdout.addStream(process.stdout);
stderr.addStream(process.stderr); stderr.addStream(process.stderr);
int code = await process.exitCode; int code = await process.exitCode;
if (code == 0) { if (code != 0) return code;
print('\n${message}');
}
} else {
print(message);
return 2;
} }
print(message);
return 0; return 0;
} }
} }
...@@ -146,6 +143,7 @@ name: {{projectName}} ...@@ -146,6 +143,7 @@ name: {{projectName}}
description: {{description}} description: {{description}}
dependencies: dependencies:
sky: any sky: any
dev_dependencies:
sky_tools: any sky_tools: any
'''; ''';
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
import 'dart:io'; import 'dart:io';
import 'package:args/args.dart'; import 'package:mockito/mockito.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:sky_tools/src/init.dart'; import 'package:sky_tools/src/init.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'src/common.dart';
main() => defineTests(); main() => defineTests();
defineTests() { defineTests() {
...@@ -26,10 +28,11 @@ defineTests() { ...@@ -26,10 +28,11 @@ defineTests() {
// Verify that we create a project that is well-formed. // Verify that we create a project that is well-formed.
test('init sky-simple', () async { test('init sky-simple', () async {
InitCommandHandler handler = new InitCommandHandler(); InitCommandHandler handler = new InitCommandHandler();
_MockArgResults results = new _MockArgResults(); MockArgResults results = new MockArgResults();
results.values['help'] = false; when(results['help']).thenReturn(false);
results.values['pub'] = true; when(results['pub']).thenReturn(true);
results.values['out'] = temp.path; when(results.wasParsed('out')).thenReturn(true);
when(results['out']).thenReturn(temp.path);
await handler.processArgResults(results); await handler.processArgResults(results);
String path = p.join(temp.path, 'lib/main.dart'); String path = p.join(temp.path, 'lib/main.dart');
expect(new File(path).existsSync(), true); expect(new File(path).existsSync(), true);
...@@ -40,14 +43,3 @@ defineTests() { ...@@ -40,14 +43,3 @@ defineTests() {
}); });
}); });
} }
class _MockArgResults implements ArgResults {
Map values = {};
operator [](String name) => values[name];
List<String> get arguments => null;
ArgResults get command => null;
String get name => null;
Iterable<String> get options => values.keys;
List<String> get rest => null;
bool wasParsed(String name) => values.containsKey(name);
}
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
library install_test; library install_test;
import 'package:args/args.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:sky_tools/src/install.dart'; import 'package:sky_tools/src/install.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'src/common.dart';
main() => defineTests(); main() => defineTests();
defineTests() { defineTests() {
...@@ -23,9 +24,3 @@ defineTests() { ...@@ -23,9 +24,3 @@ defineTests() {
}); });
}); });
} }
@proxy
class MockArgResults extends Mock implements ArgResults {
@override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:args/args.dart';
import 'package:mockito/mockito.dart';
@proxy
class MockArgResults extends Mock implements ArgResults {
@override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
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