This commit is contained in:
thosakwe 2017-03-03 23:16:15 -05:00
parent b3232b03af
commit 058e2fee39

View file

@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import "package:console/console.dart"; import "package:console/console.dart";
import 'package:pubspec/pubspec.dart';
class TestCommand extends Command { class TestCommand extends Command {
final TextPen _pen = new TextPen(); final TextPen _pen = new TextPen();
@ -15,13 +16,13 @@ class TestCommand extends Command {
run() async { run() async {
final name = await readInput("Name of Test: "), lower = name.toLowerCase(); final name = await readInput("Name of Test: "), lower = name.toLowerCase();
final testDir = new Directory("test/services"); final testDir = new Directory("test/services");
final testFile = new File.fromUri( final testFile =
testDir.uri.resolve("${lower}_test.dart")); new File.fromUri(testDir.uri.resolve("${lower}_test.dart"));
if (!await testFile.exists()) if (!await testFile.exists()) await testFile.create(recursive: true);
await testFile.create(recursive: true);
await testFile.writeAsString(_generateTest(lower)); await testFile.writeAsString(
_generateTest(await PubSpec.load(Directory.current), lower));
final runConfig = new File('./.idea/runConfigurations/${name}_tests.xml'); final runConfig = new File('./.idea/runConfigurations/${name}_tests.xml');
@ -49,10 +50,10 @@ class TestCommand extends Command {
.trim(); .trim();
} }
String _generateTest(String lower) { String _generateTest(PubSpec pubspec, String lower) {
return ''' return '''
import 'dart:io'; import 'dart:io';
import 'package:angel/angel.dart'; import 'package:${pubspec.name}/${pubspec.name}.dart';
import 'package:angel_framework/angel_framework.dart'; import 'package:angel_framework/angel_framework.dart';
import 'package:angel_test/angel_test.dart'; import 'package:angel_test/angel_test.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';