Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 library barback.test.asset_graph.source_test; | |
| 5 | |
| 6 import 'dart:async'; | |
| 7 | |
| 8 import 'package:scheduled_test/scheduled_test.dart'; | |
| 9 | |
|
nweiz
2013/06/14 00:57:57
Unnecessary blank line.
Bob Nystrom
2013/06/17 23:35:05
Done.
| |
| 10 import 'package:barback/barback.dart'; | |
| 11 import 'package:barback/src/asset_graph.dart'; | |
| 12 | |
| 13 import '../utils.dart'; | |
| 14 | |
| 15 main() { | |
| 16 initConfig(); | |
| 17 test("gets a source asset", () { | |
| 18 var provider = new MockProvider(["app|foo.txt"]); | |
| 19 var graph = new AssetGraph(provider, []); | |
| 20 graph.updateSources([AssetId.parse("app|foo.txt")]); | |
| 21 | |
| 22 expectAsset(graph, "app|foo.txt"); | |
|
nweiz
2013/06/14 00:57:57
"expectAsset" is a confusing name. I have to look
Bob Nystrom
2013/06/17 23:35:05
"exists" is a bit confusing to me because that fee
nweiz
2013/06/18 23:14:45
I don't think it's particularly weird to have a ma
Bob Nystrom
2013/06/20 00:23:59
I've got some other test refactoring I want to do
| |
| 23 }); | |
| 24 | |
| 25 test("doesn't get an unknown source", () { | |
|
nweiz
2013/06/14 00:57:57
The term "source" is confusing. I think of package
Bob Nystrom
2013/06/17 23:35:05
I'm not crazy about it either. Maybe "raw" input?
nweiz
2013/06/18 23:14:45
Sure, another patch is fine.
| |
| 26 var provider = new MockProvider(["app|foo.txt"]); | |
| 27 var graph = new AssetGraph(provider, []); | |
| 28 | |
| 29 expectNoAsset(graph, "app|unknown.txt"); | |
| 30 }); | |
| 31 | |
| 32 test("doesn't get an asset that isn't an updated source", () { | |
| 33 var provider = new MockProvider(["app|foo.txt"]); | |
| 34 var graph = new AssetGraph(provider, []); | |
| 35 | |
| 36 expectNoAsset(graph, "app|foo.txt"); | |
|
nweiz
2013/06/14 00:57:57
Wait, why will this not exist? It's right there!
Bob Nystrom
2013/06/17 23:35:05
You have to specifically tell barback "this file e
nweiz
2013/06/18 23:14:45
So how does the user specify this? If I run "pub d
Bob Nystrom
2013/06/20 00:23:59
Pub deploy will automatically call updateSources()
nweiz
2013/06/20 23:06:08
It seems a little weird that the set of available
Bob Nystrom
2013/06/21 00:13:20
The code calling barback also is responsible for g
| |
| 37 }); | |
| 38 | |
| 39 test("gets a source asset if not transformed", () { | |
| 40 var provider = new MockProvider(["app|foo.txt"]); | |
| 41 var graph = new AssetGraph(provider, [ | |
| 42 [new RewriteTransformer("nottxt", "whatever")] | |
| 43 ]); | |
| 44 graph.updateSources([AssetId.parse("app|foo.txt")]); | |
| 45 | |
| 46 expectAsset(graph, "app|foo.txt"); | |
| 47 }); | |
| 48 | |
| 49 test("doesn't get a removed source", () { | |
| 50 var provider = new MockProvider(["app|foo.txt"]); | |
| 51 var graph = new AssetGraph(provider, [[]]); | |
| 52 | |
| 53 schedule(() { | |
| 54 graph.updateSources([AssetId.parse("app|foo.txt")]); | |
|
nweiz
2013/06/14 00:57:57
Why is this [updateSources] scheduled, but the pre
Bob Nystrom
2013/06/17 23:35:05
No reason. Removed.
| |
| 55 }); | |
| 56 | |
| 57 expectAsset(graph, "app|foo.txt"); | |
| 58 | |
| 59 schedule(() { | |
| 60 graph.removeSources([AssetId.parse("app|foo.txt")]); | |
| 61 }); | |
| 62 | |
| 63 expectNoAsset(graph, "app|foo.txt"); | |
| 64 }); | |
| 65 | |
| 66 test("collapses redundant updates", () { | |
| 67 var provider = new MockProvider({"app|foo.blub": "foo"}); | |
| 68 var transformer = new RewriteTransformer("blub", "blab"); | |
| 69 var graph = new AssetGraph(provider, [[transformer]]); | |
| 70 | |
| 71 schedule(() { | |
| 72 // Make a bunch of synchronous update calls. | |
| 73 graph.updateSources([AssetId.parse("app|foo.blub")]); | |
| 74 graph.updateSources([AssetId.parse("app|foo.blub")]); | |
| 75 graph.updateSources([AssetId.parse("app|foo.blub")]); | |
| 76 graph.updateSources([AssetId.parse("app|foo.blub")]); | |
| 77 }); | |
| 78 | |
| 79 expectAsset(graph, "app|foo.blab", "foo.blab"); | |
| 80 | |
| 81 schedule(() { | |
| 82 expect(transformer.numRuns, equals(1)); | |
| 83 }); | |
| 84 }); | |
| 85 | |
| 86 test("a removal cancels out an update", () { | |
| 87 var provider = new MockProvider(["app|foo.txt"]); | |
| 88 var graph = new AssetGraph(provider, [[]]); | |
| 89 | |
| 90 schedule(() { | |
| 91 graph.updateSources([AssetId.parse("app|foo.txt")]); | |
| 92 graph.removeSources([AssetId.parse("app|foo.txt")]); | |
| 93 }); | |
| 94 | |
| 95 expectNoAsset(graph, "app|foo.txt"); | |
| 96 }); | |
| 97 | |
| 98 test("an update cancels out a removal", () { | |
| 99 var provider = new MockProvider(["app|foo.txt"]); | |
| 100 var graph = new AssetGraph(provider, [[]]); | |
| 101 | |
| 102 schedule(() { | |
| 103 graph.removeSources([AssetId.parse("app|foo.txt")]); | |
| 104 graph.updateSources([AssetId.parse("app|foo.txt")]); | |
| 105 }); | |
| 106 | |
| 107 expectAsset(graph, "app|foo.txt"); | |
| 108 }); | |
| 109 } | |
|
nweiz
2013/06/14 00:57:57
If this is where you're testing add/remove/update
Bob Nystrom
2013/06/17 23:35:05
There are some tests for this. Added a couple more
| |
| OLD | NEW |