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

Unified Diff: packages/barback/test/package_graph/get_all_assets_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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: packages/barback/test/package_graph/get_all_assets_test.dart
diff --git a/packages/barback/test/package_graph/get_all_assets_test.dart b/packages/barback/test/package_graph/get_all_assets_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..08da238cc34b414c4c5e24d4c4b64008870d5e63
--- /dev/null
+++ b/packages/barback/test/package_graph/get_all_assets_test.dart
@@ -0,0 +1,100 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.test.barback_test;
+
+import 'dart:async';
+
+import 'package:barback/barback.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../utils.dart';
+
+main() {
+ initConfig();
+
+ test("gets all source assets", () {
+ initGraph(["app|a.txt", "app|b.txt", "app|c.txt"]);
+ updateSources(["app|a.txt", "app|b.txt", "app|c.txt"]);
+ expectAllAssets(["app|a.txt", "app|b.txt", "app|c.txt"]);
+ buildShouldSucceed();
+ });
+
+ test("includes transformed outputs", () {
+ initGraph(["app|a.txt", "app|foo.blub"], {"app": [
+ [new RewriteTransformer("blub", "blab")]
+ ]});
+ updateSources(["app|a.txt", "app|foo.blub"]);
+ expectAllAssets(["app|a.txt", "app|foo.blub", "app|foo.blab"]);
+ buildShouldSucceed();
+ });
+
+ test("includes overwritten outputs", () {
+ initGraph(["app|a.txt", "app|foo.blub"], {"app": [
+ [new RewriteTransformer("blub", "blub")]
+ ]});
+ updateSources(["app|a.txt", "app|foo.blub"]);
+ expectAllAssets({
+ "app|a.txt": "a",
+ "app|foo.blub": "foo.blub"
+ });
+ buildShouldSucceed();
+ });
+
+ test("completes to an error if two transformers output the same file", () {
+ initGraph(["app|foo.a"], {"app": [
+ [
+ new RewriteTransformer("a", "b"),
+ new RewriteTransformer("a", "b")
+ ]
+ ]});
+ updateSources(["app|foo.a"]);
+ expectAllAssetsShouldFail(isAssetCollisionException("app|foo.b"));
+ });
+
+ test("completes to an error if a transformer fails", () {
+ initGraph(["app|foo.txt"], {"app": [
+ [new BadTransformer(["app|foo.out"])]
+ ]});
+
+ updateSources(["app|foo.txt"]);
+ expectAllAssetsShouldFail(isTransformerException(
+ equals(BadTransformer.ERROR)));
+ });
+
+ test("completes to an aggregate error if there are multiple errors", () {
+ initGraph(["app|foo.txt"], {"app": [
+ [
+ new BadTransformer(["app|foo.out"]),
+ new BadTransformer(["app|foo.out2"])
+ ]
+ ]});
+
+ updateSources(["app|foo.txt"]);
+ expectAllAssetsShouldFail(isAggregateException([
+ isTransformerException(equals(BadTransformer.ERROR)),
+ isTransformerException(equals(BadTransformer.ERROR))
+ ]));
+ });
+
+ // Regression test.
+ test("getAllAssets() is called synchronously after after initializing "
+ "barback", () {
+ var provider = new MockProvider({
+ "app|a.txt": "a",
+ "app|b.txt": "b",
+ "app|c.txt": "c"
+ });
+ var barback = new Barback(provider);
+ barback.updateSources([
+ new AssetId.parse("app|a.txt"),
+ new AssetId.parse("app|b.txt"),
+ new AssetId.parse("app|c.txt")
+ ]);
+
+ expect(barback.getAllAssets().then((assets) {
+ return Future.wait(assets.map((asset) => asset.readAsString()));
+ }), completion(unorderedEquals(["a", "b", "c"])));
+ });
+}
« no previous file with comments | « packages/barback/test/package_graph/errors_test.dart ('k') | packages/barback/test/package_graph/group_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698