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

Unified Diff: test/loader_http_test.dart

Issue 2638403002: Make failing HTTP requests thrown when using dart:io. (Closed)
Patch Set: Fix typo in changelog Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/loader_http_test.dart
diff --git a/test/loader_http_test.dart b/test/loader_http_test.dart
index 114ec6ac6bff01b8af1fa8527f8beff373772d83..7795f58c8c6d7f2ca70d158198ae1e1565931e3e 100644
--- a/test/loader_http_test.dart
+++ b/test/loader_http_test.dart
@@ -20,6 +20,12 @@ main() {
int port = server.port;
uri = Uri.parse("http://localhost:$port/default.html");
server.forEach((HttpRequest request) {
+ if (request.uri.path.endsWith(".not")) {
+ request.response
+ ..statusCode = HttpStatus.NOT_FOUND
+ ..close();
+ return;
+ }
var encodings = request.headers[HttpHeaders.ACCEPT_CHARSET];
var encoding = parseAcceptCharset(encodings);
request.response.headers.contentType =
@@ -61,6 +67,24 @@ main() {
expect(buffer, content.codeUnits);
});
+ test("not found - String", () async {
+ var loader = ResourceLoader.defaultLoader;
+ var badUri = uri.resolve("file.not"); // .not makes server fail.
+ expect(loader.readAsString(badUri), throws);
+ });
+
+ test("not found - bytes", () async {
+ var loader = ResourceLoader.defaultLoader;
+ var badUri = uri.resolve("file.not"); // .not makes server fail.
+ expect(loader.readAsBytes(badUri), throws);
+ });
+
+ test("not found - byte stream", () async {
+ var loader = ResourceLoader.defaultLoader;
+ var badUri = uri.resolve("file.not"); // .not makes server fail.
+ expect(loader.openRead(badUri).length, throws);
+ });
+
tearDown(() {
server.close();
server = null;
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698