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

Unified Diff: pkg/barback/test/utils.dart

Issue 22824023: Start sketching out a buildAll() method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't wrap a single error in an aggregate. Created 7 years, 4 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
Index: pkg/barback/test/utils.dart
diff --git a/pkg/barback/test/utils.dart b/pkg/barback/test/utils.dart
index 99a7ec1d19d776d8101c08aeef52dc25a0a7bba2..365525b7c6d1d36be33697b8b6091eea6535b4fe 100644
--- a/pkg/barback/test/utils.dart
+++ b/pkg/barback/test/utils.dart
@@ -9,7 +9,6 @@ import 'dart:collection';
import 'dart:io';
import 'package:barback/barback.dart';
-import 'package:barback/src/asset_set.dart';
import 'package:barback/src/cancelable_future.dart';
import 'package:barback/src/utils.dart';
import 'package:path/path.dart' as pathos;
@@ -223,6 +222,50 @@ void expectNoAsset(String name) {
}, "get asset $name");
}
+/// Schedules an expectation that the graph will output all of the given
+/// assets, and no others.
+///
+/// [assets] is a list of strings that can be parsed to [AssetID]s.
+void expectAllAssets(Iterable<String> assets) {
+ schedule(() {
+ return _barback.getAllAssets().then((actualAssets) {
+ var actualIds = actualAssets.map((asset) => asset.id).toSet();
+
+ for (var expected in assets) {
+ var id = new AssetId.parse(expected);
nweiz 2013/08/20 19:59:26 Parse these outside of [schedule] so that parse er
Bob Nystrom 2013/08/20 21:29:20 Done.
+ expect(actualIds, contains(id));
+ actualIds.remove(id);
+ }
+
+ expect(actualIds, isEmpty);
+ });
+ }, "get all assets");
+}
+
+/// Schedules an expectation that [Barback.getAllAssets] will return a [Future]
+/// that completes to a error that matches [match].
+///
+/// If [match] is a [List], then it expects the completed error to be an
+/// [AggregateException] whose errors match each matcher in the list. Otherwise,
+/// [match] should be a single matcher that the error should match.
nweiz 2013/08/20 19:59:26 It seems weird to have a one-off special case for
Bob Nystrom 2013/08/20 21:29:20 Done. The implementation of isAggregateError() fee
+void expectAllAssetsShouldFail(match) {
+ schedule(() {
+ return expect(_barback.getAllAssets().catchError((error) {
nweiz 2013/08/20 19:59:26 Returning expect doesn't do anything.
Bob Nystrom 2013/08/20 21:29:20 Done.
+ if (match is List) {
+ expect(error, new isInstanceOf<AggregateException>());
+ expect(error.errors.length, equals(match.length));
+ for (var matcher in match) {
+ expect(error.errors, contains(matcher));
+ }
+ } else {
+ expect(error, match);
+ }
+
+ throw error;
+ }), throwsA(new isInstanceOf<BarbackException>()));
+ }, "get all assets should fail");
+}
+
/// Schedules an expectation that a [getAssetById] call for the given asset
/// won't terminate at this point in the schedule.
void expectAssetDoesNotComplete(String name) {

Powered by Google App Engine
This is Rietveld 408576698