@@ -7,6 +7,8 @@ import 'dart:io';
7
7
import 'package:plugin_tool/plugin.dart' ;
8
8
import 'package:plugin_tool/runner.dart' ;
9
9
import 'package:plugin_tool/util.dart' ;
10
+ import 'package:plugin_tool/verify.dart' ;
11
+ import 'package:string_validator/string_validator.dart' as validator;
10
12
import 'package:test/test.dart' ;
11
13
12
14
void main () {
@@ -26,42 +28,76 @@ void main() {
26
28
test ('generate' , () {
27
29
expect (GenerateCommand (BuildCommandRunner ()).name, "generate" );
28
30
});
31
+
32
+ test ('verify' , () {
33
+ expect (VerifyCommand (BuildCommandRunner ()).name, "verify" );
34
+ });
29
35
});
30
36
31
37
group ("spec" , () {
38
+ /// This method has assertions which can be made for all commands in this
39
+ /// test group.
40
+ void buildSpecAssertions (BuildCommandRunner runner, String command) {
41
+ var specs = (runner.commands[command] as ProductCommand ).specs;
42
+ expect (specs, isList);
43
+ expect (specs, isNotEmpty);
44
+
45
+ // channel should be set to stable in the product-matrix.json
46
+ for (String channel in specs.map ((spec) => spec.channel).toList ()) {
47
+ expect (channel, anyOf ('stable' ));
48
+ }
49
+
50
+ // name should be set to stable in the product-matrix.json
51
+ for (String name in specs.map ((spec) => spec.name).toList ()) {
52
+ expect (name, isNotEmpty);
53
+ expect (name.length, 6 );
54
+ expect (name, validator.isFloat);
55
+ }
56
+
57
+ // ideaProduct should be android-studio or IC
58
+ for (String ideaProduct
59
+ in specs.map ((spec) => spec.ideaProduct).toList ()) {
60
+ expect (ideaProduct, anyOf ('android-studio' , 'IC' ));
61
+ }
62
+
63
+ // sinceBuild should be in the form of '243'
64
+ for (String sinceBuild in specs.map ((spec) => spec.sinceBuild).toList ()) {
65
+ expect (sinceBuild.length, 3 );
66
+ expect (sinceBuild, validator.isNumeric);
67
+ }
68
+
69
+ // untilBuild should be in the form of '243.*'
70
+ for (String untilBuild in specs.map ((spec) => spec.untilBuild).toList ()) {
71
+ expect (untilBuild.length, 5 );
72
+ expect (untilBuild.substring (0 , 2 ), validator.isNumeric);
73
+ }
74
+ }
75
+
32
76
test ('build' , () async {
33
77
var runner = makeTestRunner ();
34
78
await runner.run (["-r=19" , "-d../.." , "make" ]).whenComplete (() {
35
- var specs = (runner.commands['make' ] as ProductCommand ).specs;
36
- expect (specs, isNotNull);
37
- expect (
38
- specs.map ((spec) => spec.ideaProduct).toList (),
39
- orderedEquals (
40
- ['android-studio' , 'android-studio' , 'android-studio' , 'IC' ]));
79
+ buildSpecAssertions (runner, "make" );
41
80
});
42
81
});
43
82
44
83
test ('test' , () async {
45
84
var runner = makeTestRunner ();
46
85
await runner.run (["-r=19" , "-d../.." , "test" ]).whenComplete (() {
47
- var specs = (runner.commands['test' ] as ProductCommand ).specs;
48
- expect (specs, isNotNull);
49
- expect (
50
- specs.map ((spec) => spec.ideaProduct).toList (),
51
- orderedEquals (
52
- ['android-studio' , 'android-studio' , 'android-studio' , 'IC' ]));
86
+ buildSpecAssertions (runner, "test" );
53
87
});
54
88
});
55
89
56
90
test ('deploy' , () async {
57
91
var runner = makeTestRunner ();
58
92
await runner.run (["-r19" , "-d../.." , "deploy" ]).whenComplete (() {
59
- var specs = (runner.commands['deploy' ] as ProductCommand ).specs;
60
- expect (specs, isNotNull);
61
- expect (
62
- specs.map ((spec) => spec.ideaProduct).toList (),
63
- orderedEquals (
64
- ['android-studio' , 'android-studio' , 'android-studio' , 'IC' ]));
93
+ buildSpecAssertions (runner, "deploy" );
94
+ });
95
+ });
96
+
97
+ test ('verify' , () async {
98
+ var runner = makeTestRunner ();
99
+ await runner.run (["-r19" , "-d../.." , "verify" ]).whenComplete (() {
100
+ buildSpecAssertions (runner, "verify" );
65
101
});
66
102
});
67
103
});
@@ -159,7 +195,16 @@ void main() {
159
195
160
196
test ('only-version' , () async {
161
197
ProductCommand command =
162
- makeTestRunner ().commands['make' ] as ProductCommand ;
198
+ makeTestRunner ().commands['make' ] as ProductCommand ;
199
+ var results = command.argParser.parse (['--only-version=2023.1' ]);
200
+ expect (results['only-version' ], '2023.1' );
201
+ });
202
+ });
203
+
204
+ group ('verify' , () {
205
+ test ('only-version' , () async {
206
+ ProductCommand command =
207
+ makeTestRunner ().commands['verify' ] as ProductCommand ;
163
208
var results = command.argParser.parse (['--only-version=2023.1' ]);
164
209
expect (results['only-version' ], '2023.1' );
165
210
});
@@ -216,19 +261,10 @@ BuildCommandRunner makeTestRunner() {
216
261
runner.addCommand (TestTestCommand (runner));
217
262
runner.addCommand (TestDeployCommand (runner));
218
263
runner.addCommand (TestGenCommand (runner));
264
+ runner.addCommand (TestVerifyCommand (runner));
219
265
return runner;
220
266
}
221
267
222
- class TestMakeCommand extends GradleBuildCommand {
223
- TestMakeCommand (super .runner);
224
-
225
- @override
226
- bool get isTesting => true ;
227
-
228
- @override
229
- Future <int > doit () async => Future (() => 0 );
230
- }
231
-
232
268
class TestDeployCommand extends DeployCommand {
233
269
List <String > paths = < String > [];
234
270
List <String > plugins = < String > [];
@@ -238,16 +274,16 @@ class TestDeployCommand extends DeployCommand {
238
274
@override
239
275
bool get isTesting => true ;
240
276
277
+ @override
278
+ void changeDirectory (Directory dir) {}
279
+
241
280
String readTokenFile () {
242
281
return "token" ;
243
282
}
244
283
245
284
@override
246
- void changeDirectory (Directory dir) {}
247
-
248
- @override
249
- Future <int > upload (String filePath, String pluginNumber, String token,
250
- String channel) {
285
+ Future <int > upload (
286
+ String filePath, String pluginNumber, String token, String channel) {
251
287
paths.add (filePath);
252
288
plugins.add (pluginNumber);
253
289
return Future (() => 0 );
@@ -264,6 +300,16 @@ class TestGenCommand extends GenerateCommand {
264
300
Future <int > doit () async => Future (() => 0 );
265
301
}
266
302
303
+ class TestMakeCommand extends GradleBuildCommand {
304
+ TestMakeCommand (super .runner);
305
+
306
+ @override
307
+ bool get isTesting => true ;
308
+
309
+ @override
310
+ Future <int > doit () async => Future (() => 0 );
311
+ }
312
+
267
313
class TestTestCommand extends TestCommand {
268
314
TestTestCommand (super .runner);
269
315
@@ -273,3 +319,13 @@ class TestTestCommand extends TestCommand {
273
319
@override
274
320
Future <int > doit () async => Future (() => 0 );
275
321
}
322
+
323
+ class TestVerifyCommand extends VerifyCommand {
324
+ TestVerifyCommand (super .runner);
325
+
326
+ @override
327
+ bool get isTesting => true ;
328
+
329
+ @override
330
+ Future <int > doit () async => Future (() => 0 );
331
+ }
0 commit comments