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 metaSetUp(() { |
| 17 // TODO(nweiz): We used to only increase the timeout to 10s for the Windows |
| 18 // bots, but the Linux and Mac bots have started taking upwards of 5s when |
| 19 // running pumpEventQueue, so we're increasing the timeout across the board |
| 20 // (see issue 9248). |
| 21 currentSchedule.timeout = new Duration(seconds: 10); |
| 22 }); |
| 23 |
| 24 expectTestsPass("nothing().create() does nothing", () { |
| 25 test('test', () { |
| 26 scheduleSandbox(); |
| 27 |
| 28 d.nothing('foo').create(); |
| 29 |
| 30 schedule(() { |
| 31 expect(new File(path.join(sandbox, 'foo')).exists(), |
| 32 completion(isFalse)); |
| 33 }); |
| 34 |
| 35 schedule(() { |
| 36 expect(new Directory(path.join(sandbox, 'foo')).exists(), |
| 37 completion(isFalse)); |
| 38 }); |
| 39 }); |
| 40 }); |
| 41 |
| 42 expectTestsPass("nothing().validate() succeeds if nothing's there", () { |
| 43 test('test', () { |
| 44 scheduleSandbox(); |
| 45 |
| 46 d.nothing('foo').validate(); |
| 47 }); |
| 48 }); |
| 49 |
| 50 expectTestsPass("nothing().validate() fails if there's a file", () { |
| 51 var errors; |
| 52 test('test 1', () { |
| 53 scheduleSandbox(); |
| 54 |
| 55 currentSchedule.onException.schedule(() { |
| 56 errors = currentSchedule.errors; |
| 57 }); |
| 58 |
| 59 d.file('name.txt', 'contents').create(); |
| 60 d.nothing('name.txt').validate(); |
| 61 }); |
| 62 |
| 63 test('test 2', () { |
| 64 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 65 expect(errors.length, equals(1)); |
| 66 expect(errors.first.error, |
| 67 matches(r"^Expected nothing to exist at '[^']+[\\/]name.txt', but " |
| 68 r"found a file\.$")); |
| 69 }); |
| 70 }, passing: ['test 2']); |
| 71 |
| 72 expectTestsPass("nothing().validate() fails if there's a directory", () { |
| 73 var errors; |
| 74 test('test 1', () { |
| 75 scheduleSandbox(); |
| 76 |
| 77 currentSchedule.onException.schedule(() { |
| 78 errors = currentSchedule.errors; |
| 79 }); |
| 80 |
| 81 d.dir('dir').create(); |
| 82 d.nothing('dir').validate(); |
| 83 }); |
| 84 |
| 85 test('test 2', () { |
| 86 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
| 87 expect(errors.length, equals(1)); |
| 88 expect(errors.first.error, |
| 89 matches(r"^Expected nothing to exist at '[^']+[\\/]dir', but found a " |
| 90 r"directory\.$")); |
| 91 }); |
| 92 }, passing: ['test 2']); |
| 93 |
| 94 expectTestsPass("nothing().load() fails", () { |
| 95 test('test', () { |
| 96 scheduleSandbox(); |
| 97 |
| 98 expect(d.nothing('name.txt').load('path').toList(), |
| 99 throwsA(equals("Nothing descriptors don't support load()."))); |
| 100 }); |
| 101 }); |
| 102 |
| 103 expectTestsPass("nothing().read() fails", () { |
| 104 test('test', () { |
| 105 scheduleSandbox(); |
| 106 |
| 107 expect(d.nothing('name.txt').read().toList(), |
| 108 throwsA(equals("Nothing descriptors don't support read()."))); |
| 109 }); |
| 110 }); |
| 111 } |
OLD | NEW |