| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('reader_test'); | 5 #library('reader_test'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 #import('../../../lib/unittest/unittest.dart'); | 8 #import('../../../lib/unittest/unittest.dart'); |
| 9 #import('../../archive/archive.dart'); | 9 #import('../../archive/archive.dart'); |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 "Entry: filename3", | 42 "Entry: filename3", |
| 43 "Contents: contents 3", | 43 "Contents: contents 3", |
| 44 "Closed: filename3", | 44 "Closed: filename3", |
| 45 ])); | 45 ])); |
| 46 }, asyncDone); | 46 }, asyncDone); |
| 47 }); | 47 }); |
| 48 | 48 |
| 49 expect(future, completes); | 49 expect(future, completes); |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 test('reading a .tar.gz file with readAll', () { |
| 53 var reader = new ArchiveReader(); |
| 54 reader.format.tar = true; |
| 55 reader.filter.gzip = true; |
| 56 |
| 57 var future = reader.openFilename("$dataPath/test-archive.tar.gz") |
| 58 .chain((input) => input.readAll()) |
| 59 .transform((entries) { |
| 60 entries = entries.map((entry) => [entry.pathname, entry.contents.trim()]); |
| 61 expect(entries[0], orderedEquals(["filename1", "contents 1"])); |
| 62 expect(entries[1], orderedEquals(["filename2", "contents 2"])); |
| 63 expect(entries[2], orderedEquals(["filename3", "contents 3"])); |
| 64 }); |
| 65 |
| 66 expect(future, completes); |
| 67 }); |
| 68 |
| 52 test('reading an in-memory .tar.gz', () { | 69 test('reading an in-memory .tar.gz', () { |
| 53 var asyncDone = expectAsync0(() {}); | 70 var asyncDone = expectAsync0(() {}); |
| 54 | 71 |
| 55 var reader = new ArchiveReader(); | 72 var reader = new ArchiveReader(); |
| 56 reader.format.tar = true; | 73 reader.format.tar = true; |
| 57 reader.filter.gzip = true; | 74 reader.filter.gzip = true; |
| 58 | 75 |
| 59 var future = new File("$dataPath/test-archive.tar.gz").readAsBytes() | 76 var future = new File("$dataPath/test-archive.tar.gz").readAsBytes() |
| 60 .chain((bytes) => reader.openData(bytes)) | 77 .chain((bytes) => reader.openData(bytes)) |
| 61 .transform((input) { | 78 .transform((input) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 test("opening a non-existent archive", () { | 189 test("opening a non-existent archive", () { |
| 173 var reader = new ArchiveReader(); | 190 var reader = new ArchiveReader(); |
| 174 reader.format.tar = true; | 191 reader.format.tar = true; |
| 175 reader.filter.gzip = true; | 192 reader.filter.gzip = true; |
| 176 | 193 |
| 177 expect(reader.openFilename("$dataPath/non-existent.tar.gz"), | 194 expect(reader.openFilename("$dataPath/non-existent.tar.gz"), |
| 178 throwsA((e) => e is ArchiveException)); | 195 throwsA((e) => e is ArchiveException)); |
| 179 }); | 196 }); |
| 180 } | 197 } |
| 181 | 198 |
| OLD | NEW |