| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:io'; | |
| 6 | |
| 7 import 'package:path/path.dart' as path; | |
| 8 import 'package:scheduled_test/descriptor.dart' as d; | |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | |
| 10 | |
| 11 import 'package:metatest/metatest.dart'; | |
| 12 import 'utils.dart'; | |
| 13 | |
| 14 void main() => initTests(_test); | |
| 15 | |
| 16 void _test(message) { | |
| 17 initMetatest(message); | |
| 18 | |
| 19 setUpTimeout(); | |
| 20 | |
| 21 expectTestsPass("nothing().create() does nothing", () { | |
| 22 test('test', () { | |
| 23 scheduleSandbox(); | |
| 24 | |
| 25 d.nothing('foo').create(); | |
| 26 | |
| 27 schedule(() { | |
| 28 expect(new File(path.join(sandbox, 'foo')).exists(), | |
| 29 completion(isFalse)); | |
| 30 }); | |
| 31 | |
| 32 schedule(() { | |
| 33 expect(new Directory(path.join(sandbox, 'foo')).exists(), | |
| 34 completion(isFalse)); | |
| 35 }); | |
| 36 }); | |
| 37 }); | |
| 38 | |
| 39 expectTestsPass("nothing().validate() succeeds if nothing's there", () { | |
| 40 test('test', () { | |
| 41 scheduleSandbox(); | |
| 42 | |
| 43 d.nothing('foo').validate(); | |
| 44 }); | |
| 45 }); | |
| 46 | |
| 47 expectTestFails("nothing().validate() fails if there's a file", () { | |
| 48 scheduleSandbox(); | |
| 49 d.file('name.txt', 'contents').create(); | |
| 50 d.nothing('name.txt').validate(); | |
| 51 }, (errors) { | |
| 52 expect(errors.single, new isInstanceOf<ScheduleError>()); | |
| 53 expect(errors.single.error.toString(), | |
| 54 matches(r"^Expected nothing to exist at '[^']+[\\/]name.txt', but " | |
| 55 r"found a file\.$")); | |
| 56 }); | |
| 57 | |
| 58 expectTestFails("nothing().validate() fails if there's a directory", () { | |
| 59 scheduleSandbox(); | |
| 60 d.dir('dir').create(); | |
| 61 d.nothing('dir').validate(); | |
| 62 }, (errors) { | |
| 63 expect(errors.single, new isInstanceOf<ScheduleError>()); | |
| 64 expect(errors.single.error.toString(), | |
| 65 matches(r"^Expected nothing to exist at '[^']+[\\/]dir', but found a " | |
| 66 r"directory\.$")); | |
| 67 }); | |
| 68 | |
| 69 expectTestFails("nothing().validate() fails if there's a broken link", () { | |
| 70 scheduleSandbox(); | |
| 71 schedule(() { | |
| 72 new Link(path.join(sandbox, 'link')).createSync('nonexistent'); | |
| 73 }); | |
| 74 d.nothing('link').validate(); | |
| 75 }, (errors) { | |
| 76 expect(errors.single, new isInstanceOf<ScheduleError>()); | |
| 77 expect(errors.single.error.toString(), | |
| 78 matches(r"^Expected nothing to exist at '[^']+[\\/]link', but found " | |
| 79 r"a link\.$")); | |
| 80 }); | |
| 81 } | |
| OLD | NEW |