Skip to content

Commit cc2d4bc

Browse files
committed
move matchers to common test file
1 parent 49c9c6a commit cc2d4bc

File tree

4 files changed

+51
-39
lines changed

4 files changed

+51
-39
lines changed

test/asset/file_based_test.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44
@TestOn('vm')
5-
import 'dart:async';
65
import 'dart:io';
76

87
import 'package:test/test.dart';
98

109
import 'package:build/build.dart';
10+
1111
import '../common/common.dart';
1212

13+
final packageGraph = new PackageGraph.forPath('test/fixtures/basic_pkg');
14+
1315
main() async {
14-
final packageGraph = new PackageGraph.forPath('test/fixtures/basic_pkg');
15-
final assetNotFoundException = new isInstanceOf<AssetNotFoundException>();
16-
final invalidInputException = new isInstanceOf<InvalidInputException>();
17-
final invalidOutputException = new isInstanceOf<InvalidOutputException>();
18-
final packageNotFoundException = new isInstanceOf<PackageNotFoundException>();
1916

2017
group('FileBasedAssetReader', () {
2118
final reader = new FileBasedAssetReader(packageGraph);

test/common/assets.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2016, 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+
import 'package:build/build.dart';
5+
6+
import 'in_memory_writer.dart';
7+
8+
int _nextId = 0;
9+
AssetId makeAssetId([String assetIdString]) {
10+
if (assetIdString == null) {
11+
assetIdString = 'a|web/asset_$_nextId.txt';
12+
_nextId++;
13+
}
14+
return new AssetId.parse(assetIdString);
15+
}
16+
17+
Asset makeAsset([String assetIdString, String contents]) {
18+
var id = makeAssetId(assetIdString);
19+
return new Asset(id, contents ?? '$id');
20+
}
21+
22+
Map<AssetId, Asset> makeAssets(Map<String, String> assetsMap) {
23+
var assets = <AssetId, Asset>{};
24+
assetsMap.forEach((idString, content) {
25+
var asset = makeAsset(idString, content);
26+
assets[asset.id] = asset;
27+
});
28+
return assets;
29+
}
30+
31+
void addAssets(Iterable<Asset> assets, InMemoryAssetWriter writer) {
32+
for (var asset in assets) {
33+
writer.assets[asset.id] = asset.stringContents;
34+
}
35+
}

test/common/common.dart

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,12 @@
11
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
4-
import 'package:build/build.dart';
5-
6-
import 'in_memory_writer.dart';
7-
4+
export 'assets.dart';
85
export 'copy_builder.dart';
96
export 'file_combiner_builder.dart';
107
export 'in_memory_reader.dart';
118
export 'in_memory_writer.dart';
129
export 'generic_builder_transformer.dart';
10+
export 'matchers.dart';
1311
export 'stub_reader.dart';
1412
export 'stub_writer.dart';
15-
16-
int _nextId = 0;
17-
AssetId makeAssetId([String assetIdString]) {
18-
if (assetIdString == null) {
19-
assetIdString = 'a|web/asset_$_nextId.txt';
20-
_nextId++;
21-
}
22-
return new AssetId.parse(assetIdString);
23-
}
24-
25-
Asset makeAsset([String assetIdString, String contents]) {
26-
var id = makeAssetId(assetIdString);
27-
return new Asset(id, contents ?? '$id');
28-
}
29-
30-
Map<AssetId, Asset> makeAssets(Map<String, String> assetsMap) {
31-
var assets = <AssetId, Asset>{};
32-
assetsMap.forEach((idString, content) {
33-
var asset = makeAsset(idString, content);
34-
assets[asset.id] = asset;
35-
});
36-
return assets;
37-
}
38-
39-
void addAssets(Iterable<Asset> assets, InMemoryAssetWriter writer) {
40-
for (var asset in assets) {
41-
writer.assets[asset.id] = asset.stringContents;
42-
}
43-
}

test/common/matchers.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2016, 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+
import 'package:test/test.dart';
5+
6+
import 'package:build/build.dart';
7+
8+
final assetNotFoundException = new isInstanceOf<AssetNotFoundException>();
9+
final invalidInputException = new isInstanceOf<InvalidInputException>();
10+
final invalidOutputException = new isInstanceOf<InvalidOutputException>();
11+
final packageNotFoundException = new isInstanceOf<PackageNotFoundException>();

0 commit comments

Comments
 (0)