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:async'; |
| 6 import 'dart:io'; |
| 7 |
| 8 import 'package:pathos/path.dart' as path; |
| 9 import 'package:scheduled_test/descriptor.dart' as d; |
| 10 import 'package:scheduled_test/scheduled_test.dart'; |
| 11 |
| 12 import '../metatest.dart'; |
| 13 import 'utils.dart'; |
| 14 |
| 15 void main() { |
| 16 setUpTimeout(); |
| 17 |
| 18 expectTestsPass("nothing().create() does nothing", () { |
| 19 test('test', () { |
| 20 scheduleSandbox(); |
| 21 |
| 22 d.nothing('foo').create(); |
| 23 |
| 24 schedule(() { |
| 25 expect(new File(path.join(sandbox, 'foo')).exists(), |
| 26 completion(isFalse)); |
| 27 }); |
| 28 |
| 29 schedule(() { |
| 30 expect(new Directory(path.join(sandbox, 'foo')).exists(), |
| 31 completion(isFalse)); |
| 32 }); |
| 33 }); |
| 34 }); |
| 35 |
| 36 expectTestsPass("nothing().validate() succeeds if nothing's there", () { |
| 37 test('test', () { |
| 38 scheduleSandbox(); |
| 39 |
| 40 d.nothing('foo').validate(); |
| 41 }); |
| 42 }); |
| 43 |
| 44 expectTestsPass("nothing().validate() fails if there's a file", () { |
| 45 var errors; |
| 46 test('test 1', () { |
| 47 scheduleSandbox(); |
| 48 |
| 49 currentSchedule.onException.schedule(() { |
| 50 errors = currentSchedule.errors; |
| 51 }); |
| 52 |
| 53 d.file('name.txt', 'contents').create(); |
| 54 d.nothing('name.txt').validate(); |
| 55 }); |
| 56 |
| 57 test('test 2', () { |
| 58 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 59 expect(errors.length, equals(1)); |
| 60 expect(errors.first.error, |
| 61 matches(r"^Expected nothing to exist at '[^']+[\\/]name.txt', but " |
| 62 r"found a file\.$")); |
| 63 }); |
| 64 }, passing: ['test 2']); |
| 65 |
| 66 expectTestsPass("nothing().validate() fails if there's a directory", () { |
| 67 var errors; |
| 68 test('test 1', () { |
| 69 scheduleSandbox(); |
| 70 |
| 71 currentSchedule.onException.schedule(() { |
| 72 errors = currentSchedule.errors; |
| 73 }); |
| 74 |
| 75 d.dir('dir').create(); |
| 76 d.nothing('dir').validate(); |
| 77 }); |
| 78 |
| 79 test('test 2', () { |
| 80 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 81 expect(errors.length, equals(1)); |
| 82 expect(errors.first.error, |
| 83 matches(r"^Expected nothing to exist at '[^']+[\\/]dir', but found a " |
| 84 r"directory\.$")); |
| 85 }); |
| 86 }, passing: ['test 2']); |
| 87 |
| 88 expectTestsPass("nothing().load() fails", () { |
| 89 test('test', () { |
| 90 scheduleSandbox(); |
| 91 |
| 92 expect(d.nothing('name.txt').load('path').toList(), |
| 93 throwsA(equals("Nothing descriptors don't support load()."))); |
| 94 }); |
| 95 }); |
| 96 |
| 97 expectTestsPass("nothing().read() fails", () { |
| 98 test('test', () { |
| 99 scheduleSandbox(); |
| 100 |
| 101 expect(d.nothing('name.txt').read().toList(), |
| 102 throwsA(equals("Nothing descriptors don't support read()."))); |
| 103 }); |
| 104 }); |
| 105 } |
OLD | NEW |