Skip to content

Commit 445cb0a

Browse files
authored
[hooks_runner] Make user-defines test work without data assets (#2624)
1 parent cdffa83 commit 445cb0a

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

pkgs/hooks_runner/test/test_data/user_defines_test.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
@OnPlatform({'mac-os': Timeout.factor(2), 'windows': Timeout.factor(10)})
66
library;
77

8-
import 'dart:io';
9-
10-
import 'package:data_assets/data_assets.dart';
11-
import 'package:file_testing/file_testing.dart';
128
import 'package:hooks_runner/hooks_runner.dart';
139
import 'package:hooks_runner/src/build_runner/build_runner.dart';
1410
import 'package:test/test.dart';
@@ -38,13 +34,7 @@ void main() async {
3834
userDefines: UserDefines(workspacePubspec: pubspecUri),
3935
)).success;
4036

41-
final dataAssets = result.encodedAssets
42-
.map((e) => e.asDataAsset)
43-
.toList();
44-
expect(dataAssets.length, 2);
45-
for (final dataAsset in dataAssets) {
46-
expect(File.fromUri(dataAsset.file), exists);
47-
}
37+
expect(result.encodedAssets.length, 0);
4838

4939
// The native assets build runner must be reinvoked if the pubspec
5040
// changes, as the pubspec could contain user-defines.

pkgs/hooks_runner/test_data/user_defines/hook/build.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
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

5-
import 'dart:convert';
65
import 'dart:io';
76

8-
import 'package:data_assets/data_assets.dart';
97
import 'package:hooks/hooks.dart';
108

119
void main(List<String> arguments) async {
@@ -17,13 +15,11 @@ void main(List<String> arguments) async {
1715
);
1816
}
1917
final value2 = input.userDefines['user_define_key2'];
20-
final dataAsset = DataAsset(
21-
file: input.outputDirectoryShared.resolve('my_asset.json'),
22-
name: 'my_asset',
23-
package: input.packageName,
24-
);
25-
File.fromUri(dataAsset.file).writeAsStringSync(jsonEncode(value2));
26-
output.assets.data.add(dataAsset);
18+
if (value2 == null) {
19+
throw Exception(
20+
'User-define user_define_key2 does not have the right value: $value2',
21+
);
22+
}
2723

2824
// Load some relative path as absolute path from user-defines.
2925
final someFile = input.userDefines.path('some_file');
@@ -35,8 +31,5 @@ void main(List<String> arguments) async {
3531
}
3632
final file = File.fromUri(someFile);
3733
output.dependencies.add(file.uri);
38-
output.assets.data.add(
39-
DataAsset(file: file.uri, name: 'data.json', package: input.packageName),
40-
);
4134
});
4235
}

0 commit comments

Comments
 (0)