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:
stdout.addStream(process.stdout);
stderr.addStream(process.stderr);
int code = await process.exitCode;
if (code == 0) {
print('\n${message}');
}
} else {
print(message);
return 2;
if (code != 0) return code;
}
print(message);
return 0;
}
}
......@@ -146,6 +143,7 @@ name: {{projectName}}
description: {{description}}
dependencies:
sky: any
dev_dependencies:
sky_tools: any
''';
......
......@@ -4,11 +4,13 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:mockito/mockito.dart';
import 'package:path/path.dart' as p;
import 'package:sky_tools/src/init.dart';
import 'package:test/test.dart';
import 'src/common.dart';
main() => defineTests();
defineTests() {
......@@ -26,10 +28,11 @@ defineTests() {
// Verify that we create a project that is well-formed.
test('init sky-simple', () async {
InitCommandHandler handler = new InitCommandHandler();
_MockArgResults results = new _MockArgResults();
results.values['help'] = false;
results.values['pub'] = true;
results.values['out'] = temp.path;
MockArgResults results = new MockArgResults();
when(results['help']).thenReturn(false);
when(results['pub']).thenReturn(true);
when(results.wasParsed('out')).thenReturn(true);
when(results['out']).thenReturn(temp.path);
await handler.processArgResults(results);
String path = p.join(temp.path, 'lib/main.dart');
expect(new File(path).existsSync(), true);
......@@ -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 @@
library install_test;
import 'package:args/args.dart';
import 'package:mockito/mockito.dart';
import 'package:sky_tools/src/install.dart';
import 'package:test/test.dart';
import 'src/common.dart';
main() => defineTests();
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