Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Side by Side Diff: pkg/scheduled_test/test/descriptor/directory_test.dart

Issue 15682008: Allow DirectoryDescriptor.load to load a file next to a directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:pathos/path.dart' as path; 8 import 'package:pathos/path.dart' as path;
9 import 'package:scheduled_test/descriptor.dart' as d; 9 import 'package:scheduled_test/descriptor.dart' as d;
10 import 'package:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 d.file('name.txt', 'subcontents') 284 d.file('name.txt', 'subcontents')
285 ]), 285 ]),
286 d.file('name.txt', 'contents') 286 d.file('name.txt', 'contents')
287 ]); 287 ]);
288 288
289 expect(byteStreamToString(dir.load('subdir/name.txt')), 289 expect(byteStreamToString(dir.load('subdir/name.txt')),
290 completion(equals('subcontents'))); 290 completion(equals('subcontents')));
291 }); 291 });
292 }); 292 });
293 293
294 expectTestsPass("directory().read() fails", () {
295 test('test', () {
296 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
297 expect(dir.read().toList(),
298 throwsA(equals("Can't read the contents of 'dir': is a directory.")));
299 });
300 });
301
302 expectTestsPass("directory().load() fails to load a nested directory", () { 294 expectTestsPass("directory().load() fails to load a nested directory", () {
303 test('test', () { 295 test('test', () {
304 var dir = d.dir('dir', [ 296 var dir = d.dir('dir', [
305 d.dir('subdir', [ 297 d.dir('subdir', [
306 d.file('name.txt', 'subcontents') 298 d.file('name.txt', 'subcontents')
307 ]), 299 ]),
308 d.file('name.txt', 'contents') 300 d.file('name.txt', 'contents')
309 ]); 301 ]);
310 302
311 expect(dir.load('subdir').toList(), 303 expect(dir.load('subdir').toList(),
312 throwsA(equals("Can't read the contents of 'subdir': is a " 304 throwsA(equals("Couldn't find a readable entry named 'subdir' within "
313 "directory."))); 305 "'dir'.")));
314 }); 306 });
315 }); 307 });
316 308
317 expectTestsPass("directory().load() fails to load an absolute path", () { 309 expectTestsPass("directory().load() fails to load an absolute path", () {
318 test('test', () { 310 test('test', () {
319 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 311 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
320 312
321 expect(dir.load('/name.txt').toList(), 313 expect(dir.load('/name.txt').toList(),
322 throwsA(equals("Can't load absolute path '/name.txt'."))); 314 throwsA(equals("Can't load absolute path '/name.txt'.")));
323 }); 315 });
(...skipping 13 matching lines...) Expand all
337 throwsA(equals("Can't load '' from within 'dir'."))); 329 throwsA(equals("Can't load '' from within 'dir'.")));
338 }); 330 });
339 }); 331 });
340 332
341 expectTestsPass("directory().load() fails to load a file that doesn't exist", 333 expectTestsPass("directory().load() fails to load a file that doesn't exist",
342 () { 334 () {
343 test('test', () { 335 test('test', () {
344 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 336 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
345 337
346 expect(dir.load('not-name.txt').toList(), 338 expect(dir.load('not-name.txt').toList(),
347 throwsA(equals("Couldn't find an entry named 'not-name.txt' within " 339 throwsA(equals("Couldn't find a readable entry named 'not-name.txt' "
348 "'dir'."))); 340 "within 'dir'.")));
349 }); 341 });
350 }); 342 });
351 343
352 expectTestsPass("directory().load() fails to load a file that exists " 344 expectTestsPass("directory().load() fails to load a file that exists "
353 "multiple times", () { 345 "multiple times", () {
354 test('test', () { 346 test('test', () {
355 var dir = d.dir('dir', [ 347 var dir = d.dir('dir', [
356 d.file('name.txt', 'contents'), 348 d.file('name.txt', 'contents'),
357 d.file('name.txt', 'contents') 349 d.file('name.txt', 'contents')
358 ]); 350 ]);
359 351
360 expect(dir.load('name.txt').toList(), 352 expect(dir.load('name.txt').toList(),
361 throwsA(equals("Found multiple entries named 'name.txt' within " 353 throwsA(equals("Found multiple readable entries named 'name.txt' "
362 "'dir'."))); 354 "within 'dir'.")));
363 }); 355 });
364 }); 356 });
365 357
358 expectTestsPass("directory().load() loads a file next to a subdirectory with "
359 "the same name", () {
360 test('test', () {
361 var dir = d.dir('dir', [
362 d.file('name', 'contents'),
363 d.dir('name', [d.file('subfile', 'contents')])
364 ]);
365
366 expect(byteStreamToString(dir.load('name')),
367 completion(equals('contents')));
368 });
369 });
370
366 expectTestsPass("directory().describe() lists the contents of the directory", 371 expectTestsPass("directory().describe() lists the contents of the directory",
367 () { 372 () {
368 test('test', () { 373 test('test', () {
369 var dir = d.dir('dir', [ 374 var dir = d.dir('dir', [
370 d.file('file1.txt', 'contents1'), 375 d.file('file1.txt', 'contents1'),
371 d.file('file2.txt', 'contents2') 376 d.file('file2.txt', 'contents2')
372 ]); 377 ]);
373 378
374 expect(dir.describe(), equals( 379 expect(dir.describe(), equals(
375 "dir\n" 380 "dir\n"
(...skipping 29 matching lines...) Expand all
405 }); 410 });
406 }); 411 });
407 412
408 expectTestsPass("directory().describe() with no contents returns the " 413 expectTestsPass("directory().describe() with no contents returns the "
409 "directory name", () { 414 "directory name", () {
410 test('test', () { 415 test('test', () {
411 expect(d.dir('dir').describe(), equals('dir')); 416 expect(d.dir('dir').describe(), equals('dir'));
412 }); 417 });
413 }); 418 });
414 } 419 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/descriptor/async_test.dart ('k') | pkg/scheduled_test/test/descriptor/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698