OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library docs_test; | 5 library docs_test; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
11 import '../bin/docs.dart'; | 11 import '../bin/docs.dart'; |
12 import '../lib/docs.dart'; | 12 import '../lib/docs.dart'; |
13 | 13 |
14 final testJsonPath = scriptDir.append('test.json').canonicalize(); | 14 final testJsonPath = scriptDir.append('test.json').canonicalize(); |
15 | 15 |
16 main() { | 16 main() { |
17 test('Ensure that docs.json is up to date', () { | 17 group('docs', () { |
Emily Fortuna
2013/04/01 17:41:20
if there's only one test, there's no real compelli
Andrei Mouravski
2013/04/01 22:43:07
It's the only way to register the tearDown() to ha
| |
18 var oldJson = new File.fromPath(json_path); | 18 var oldJson = new File.fromPath(json_path); |
19 var testJson = new File.fromPath(testJsonPath); | 19 var testJson = new File.fromPath(testJsonPath); |
20 | 20 |
21 // We should find a json file where we expect it. | 21 tearDown(() { |
22 expect(oldJson.existsSync(), isTrue); | |
23 | |
24 // Save the last modified time to check it at the end. | |
25 var oldJsonModified = oldJson.lastModifiedSync(); | |
26 | |
27 // There should be no test file yet. | |
28 if (testJson.existsSync()) testJson.deleteSync(); | |
29 expect(testJson.existsSync(), isFalse); | |
30 | |
31 expect(convert(lib_path, testJsonPath) | |
32 .then((bool anyErrors) { | |
33 expect(anyErrors, isFalse); | |
34 | |
35 // We should have a file now. | |
36 expect(testJson.existsSync(), isTrue); | |
37 | |
38 // Ensure that there's nothing different between the new JSON and old. | |
39 expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync())); | |
40 | |
41 // Ensure that the old JSON file didn't actually change. | |
42 expect(oldJsonModified, equals(oldJson.lastModifiedSync())); | |
43 | |
44 // Clean up. | 22 // Clean up. |
45 if (testJson.existsSync()) { | 23 if (testJson.existsSync()) { |
46 testJson.deleteSync(); | 24 testJson.deleteSync(); |
47 } | 25 } |
48 expect(testJson.existsSync(), isFalse); | 26 assert(!testJson.existsSync()); |
49 }), completes); | 27 }); |
28 | |
29 test('Ensure that docs.json is up to date', () { | |
30 // We should find a json file where we expect it. | |
31 expect(oldJson.existsSync(), isTrue); | |
32 | |
33 // Save the last modified time to check it at the end. | |
34 var oldJsonModified = oldJson.lastModifiedSync(); | |
35 | |
36 // There should be no test file yet. | |
37 if (testJson.existsSync()) testJson.deleteSync(); | |
38 assert(!testJson.existsSync()); | |
39 | |
40 expect(convert(lib_path, testJsonPath) | |
41 .then((bool anyErrors) { | |
42 expect(anyErrors, isFalse); | |
43 | |
44 // We should have a file now. | |
45 expect(testJson.existsSync(), isTrue); | |
46 | |
47 // Ensure that there's nothing different between the new JSON and old. | |
48 expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync())); | |
49 | |
50 // Ensure that the old JSON file didn't actually change. | |
51 expect(oldJsonModified, equals(oldJson.lastModifiedSync())); | |
52 }), completes); | |
53 }); | |
50 }); | 54 }); |
51 } | 55 } |
OLD | NEW |