Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
migrate to pkg/test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed May 13, 2015
1 parent 23b0a5e commit ad766af
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 93 deletions.
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ dev_dependencies:
browser: ^0.10.0
ghpages_generator: ^0.2.4
grinder: ^0.7.0
unittest: ^0.11.0
test: ^0.12.0
6 changes: 3 additions & 3 deletions test/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'common_test.dart' as common_test;
import 'generators_test.dart' as generators_test;

void main() {
cli_test.defineTests();
common_test.defineTests();
generators_test.defineTests();
cli_test.main();
common_test.main();
generators_test.main();
}
6 changes: 3 additions & 3 deletions test/cli_test.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

@TestOn('vm')
library stagehand.cli_test;

import 'dart:async';
Expand All @@ -10,10 +10,10 @@ import 'dart:io';

import 'package:stagehand/stagehand.dart';
import 'package:stagehand/src/cli_app.dart';
import 'package:unittest/unittest.dart';
import 'package:test/test.dart';
import 'package:usage/usage.dart';

void defineTests() {
void main() {
group('cli', () {
CliApp app;
CliLoggerMock logger;
Expand Down
4 changes: 2 additions & 2 deletions test/common_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
library stagehand.common_test;

import 'package:stagehand/src/common.dart';
import 'package:unittest/unittest.dart';
import 'package:test/test.dart';

void defineTests() {
void main() {
group('common', () {
test('normalizeProjectName', () {
expect(normalizeProjectName('foo.dart'), 'foo');
Expand Down
4 changes: 2 additions & 2 deletions test/generators_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
library stagehand.generators_test;

import 'package:stagehand/stagehand.dart';
import 'package:unittest/unittest.dart';
import 'package:test/test.dart';

void defineTests() {
void main() {
group('generators', () {
generators.forEach((generator) {
test(generator.id, () => validate(getGenerator(generator.id)));
Expand Down
45 changes: 45 additions & 0 deletions test/mock_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2014, Google Inc. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

library stagehand.mock_test;

import 'dart:async';

import 'package:stagehand/stagehand.dart';
import 'package:test/test.dart';

void main() {
for (var generator in generators) {
test(generator.id, () => _testGenerator(getGenerator(generator.id)));
}
}

Future _testGenerator(Generator generator) async {
expect(generator.id, isNotNull);

MockTarget target = new MockTarget();

// Assert that we can generate the template.
await generator.generate('foo', target);

// Run some basic validation on the generated results.
expect(target.getFileContentsAsString('.gitignore'), isNotNull);
expect(target.getFileContentsAsString('pubspec.yaml'), isNotNull);
}

class MockTarget extends GeneratorTarget {
Map<String, List<int>> files = {};

Future createFile(String path, List<int> contents) {
files[path] = contents;
return new Future.value();
}

bool hasFile(String path) => files.containsKey(path);

String getFileContentsAsString(String path) {
if (!hasFile(path)) return null;
return new String.fromCharCodes(files[path]);
}
}
19 changes: 0 additions & 19 deletions test/web.html

This file was deleted.

63 changes: 0 additions & 63 deletions test/web_test.dart

This file was deleted.

0 comments on commit ad766af

Please sign in to comment.