| Index: pkg/barback/test/asset_graph/source_test.dart
|
| diff --git a/pkg/barback/test/asset_graph/source_test.dart b/pkg/barback/test/asset_graph/source_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dbcea9f64724a6f4f7c6ed2ecdcbd7f35b4271e7
|
| --- /dev/null
|
| +++ b/pkg/barback/test/asset_graph/source_test.dart
|
| @@ -0,0 +1,105 @@
|
| +// 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.asset_graph.source_test;
|
| +
|
| +import 'dart:async';
|
| +
|
| +import 'package:barback/barback.dart';
|
| +import 'package:barback/src/asset_graph.dart';
|
| +import 'package:scheduled_test/scheduled_test.dart';
|
| +
|
| +import '../utils.dart';
|
| +
|
| +main() {
|
| + initConfig();
|
| + test("gets a source asset", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, []);
|
| + graph.updateSources([new AssetId.parse("app|foo.txt")]);
|
| +
|
| + expectAsset(graph, "app|foo.txt");
|
| + });
|
| +
|
| + test("doesn't get an unknown source", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, []);
|
| +
|
| + expectNoAsset(graph, "app|unknown.txt");
|
| + });
|
| +
|
| + test("doesn't get an asset that isn't an updated source", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, []);
|
| +
|
| + expectNoAsset(graph, "app|foo.txt");
|
| + });
|
| +
|
| + test("gets a source asset if not transformed", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, [
|
| + [new RewriteTransformer("nottxt", "whatever")]
|
| + ]);
|
| + graph.updateSources([new AssetId.parse("app|foo.txt")]);
|
| +
|
| + expectAsset(graph, "app|foo.txt");
|
| + });
|
| +
|
| + test("doesn't get a removed source", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, [[]]);
|
| + graph.updateSources([new AssetId.parse("app|foo.txt")]);
|
| +
|
| + expectAsset(graph, "app|foo.txt");
|
| +
|
| + schedule(() {
|
| + graph.removeSources([new AssetId.parse("app|foo.txt")]);
|
| + });
|
| +
|
| + expectNoAsset(graph, "app|foo.txt");
|
| + });
|
| +
|
| + test("collapses redundant updates", () {
|
| + var provider = new MockProvider({"app|foo.blub": "foo"});
|
| + var transformer = new RewriteTransformer("blub", "blab");
|
| + var graph = new AssetGraph(provider, [[transformer]]);
|
| +
|
| + schedule(() {
|
| + // Make a bunch of synchronous update calls.
|
| + graph.updateSources([new AssetId.parse("app|foo.blub")]);
|
| + graph.updateSources([new AssetId.parse("app|foo.blub")]);
|
| + graph.updateSources([new AssetId.parse("app|foo.blub")]);
|
| + graph.updateSources([new AssetId.parse("app|foo.blub")]);
|
| + });
|
| +
|
| + expectAsset(graph, "app|foo.blab", "foo.blab");
|
| +
|
| + schedule(() {
|
| + expect(transformer.numRuns, equals(1));
|
| + });
|
| + });
|
| +
|
| + test("a removal cancels out an update", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, [[]]);
|
| +
|
| + schedule(() {
|
| + graph.updateSources([new AssetId.parse("app|foo.txt")]);
|
| + graph.removeSources([new AssetId.parse("app|foo.txt")]);
|
| + });
|
| +
|
| + expectNoAsset(graph, "app|foo.txt");
|
| + });
|
| +
|
| + test("an update cancels out a removal", () {
|
| + var provider = new MockProvider(["app|foo.txt"]);
|
| + var graph = new AssetGraph(provider, [[]]);
|
| +
|
| + schedule(() {
|
| + graph.removeSources([new AssetId.parse("app|foo.txt")]);
|
| + graph.updateSources([new AssetId.parse("app|foo.txt")]);
|
| + });
|
| +
|
| + expectAsset(graph, "app|foo.txt");
|
| + });
|
| +}
|
|
|