@@ -40,13 +40,17 @@ void main() {
40
40
const allowedArgument = '--allowed' ;
41
41
42
42
late Progress progress;
43
+ late Directory tempDirectory;
43
44
44
45
setUpAll (() {
45
46
registerFallbackValue ('' );
46
47
});
47
48
48
49
setUp (() {
49
50
progress = _MockProgress ();
51
+
52
+ tempDirectory = Directory .systemTemp.createTempSync ();
53
+ addTearDown (() => tempDirectory.deleteSync (recursive: true ));
50
54
});
51
55
52
56
test (
@@ -103,9 +107,6 @@ void main() {
103
107
'''when there is a single hosted direct dependency and license''' ,
104
108
withRunner (
105
109
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
106
- final tempDirectory = Directory .systemTemp.createTempSync ();
107
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
108
-
109
110
File (path.join (tempDirectory.path, pubspecLockBasename))
110
111
.writeAsStringSync (_validPubspecLockContent);
111
112
@@ -134,9 +135,6 @@ void main() {
134
135
'''when there are multiple hosted direct dependency and licenses''' ,
135
136
withRunner (
136
137
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
137
- final tempDirectory = Directory .systemTemp.createTempSync ();
138
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
139
-
140
138
File (path.join (tempDirectory.path, pubspecLockBasename))
141
139
.writeAsStringSync (_validMultiplePubspecLockContent);
142
140
@@ -173,9 +171,6 @@ void main() {
173
171
'''when both allowed and forbidden are specified but left empty''' ,
174
172
withRunner (
175
173
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
176
- final tempDirectory = Directory .systemTemp.createTempSync ();
177
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
178
-
179
174
File (path.join (tempDirectory.path, pubspecLockBasename))
180
175
.writeAsStringSync (_validPubspecLockContent);
181
176
@@ -217,9 +212,6 @@ void main() {
217
212
'when a PubLicenseException is thrown' ,
218
213
withRunner (
219
214
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
220
- final tempDirectory = Directory .systemTemp.createTempSync ();
221
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
222
-
223
215
File (path.join (tempDirectory.path, pubspecLockBasename))
224
216
.writeAsStringSync (_validMultiplePubspecLockContent);
225
217
@@ -266,9 +258,6 @@ void main() {
266
258
'when an unknown error is thrown' ,
267
259
withRunner (
268
260
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
269
- final tempDirectory = Directory .systemTemp.createTempSync ();
270
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
271
-
272
261
File (path.join (tempDirectory.path, pubspecLockBasename))
273
262
.writeAsStringSync (_validMultiplePubspecLockContent);
274
263
@@ -316,9 +305,6 @@ void main() {
316
305
'when all licenses fail to be retrieved' ,
317
306
withRunner (
318
307
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
319
- final tempDirectory = Directory .systemTemp.createTempSync ();
320
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
321
-
322
308
File (path.join (tempDirectory.path, pubspecLockBasename))
323
309
.writeAsStringSync (_validMultiplePubspecLockContent);
324
310
@@ -418,9 +404,6 @@ void main() {
418
404
pubLicense,
419
405
printLogs,
420
406
) async {
421
- final tempDirectory = Directory .systemTemp.createTempSync ();
422
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
423
-
424
407
File (path.join (tempDirectory.path, pubspecLockBasename))
425
408
.writeAsStringSync (_validPubspecLockContent);
426
409
@@ -464,9 +447,6 @@ void main() {
464
447
pubLicense,
465
448
printLogs,
466
449
) async {
467
- final tempDirectory = Directory .systemTemp.createTempSync ();
468
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
469
-
470
450
File (path.join (tempDirectory.path, pubspecLockBasename))
471
451
.writeAsStringSync (_validPubspecLockContent);
472
452
@@ -516,9 +496,6 @@ void main() {
516
496
pubLicense,
517
497
printLogs,
518
498
) async {
519
- final tempDirectory = Directory .systemTemp.createTempSync ();
520
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
521
-
522
499
File (path.join (tempDirectory.path, pubspecLockBasename))
523
500
.writeAsStringSync (_validPubspecLockContent);
524
501
@@ -567,9 +544,6 @@ void main() {
567
544
pubLicense,
568
545
printLogs,
569
546
) async {
570
- final tempDirectory = Directory .systemTemp.createTempSync ();
571
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
572
-
573
547
File (path.join (tempDirectory.path, pubspecLockBasename))
574
548
.writeAsStringSync (_validPubspecLockContent);
575
549
@@ -618,9 +592,6 @@ void main() {
618
592
pubLicense,
619
593
printLogs,
620
594
) async {
621
- final tempDirectory = Directory .systemTemp.createTempSync ();
622
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
623
-
624
595
File (path.join (tempDirectory.path, pubspecLockBasename))
625
596
.writeAsStringSync (_validPubspecLockContent);
626
597
@@ -682,9 +653,6 @@ void main() {
682
653
'warns when a license is not recognized' ,
683
654
withRunner (
684
655
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
685
- final tempDirectory = Directory .systemTemp.createTempSync ();
686
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
687
-
688
656
File (path.join (tempDirectory.path, pubspecLockBasename))
689
657
.writeAsStringSync (_validPubspecLockContent);
690
658
@@ -716,9 +684,6 @@ void main() {
716
684
'exits when a license is not allowed' ,
717
685
withRunner (
718
686
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
719
- final tempDirectory = Directory .systemTemp.createTempSync ();
720
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
721
-
722
687
File (path.join (tempDirectory.path, pubspecLockBasename))
723
688
.writeAsStringSync (_validPubspecLockContent);
724
689
@@ -745,9 +710,6 @@ void main() {
745
710
'when a single license is not allowed' ,
746
711
withRunner (
747
712
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
748
- final tempDirectory = Directory .systemTemp.createTempSync ();
749
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
750
-
751
713
File (path.join (tempDirectory.path, pubspecLockBasename))
752
714
.writeAsStringSync (_validMultiplePubspecLockContent);
753
715
@@ -787,9 +749,6 @@ void main() {
787
749
'when a single license is not allowed and forbidden is left empty' ,
788
750
withRunner (
789
751
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
790
- final tempDirectory = Directory .systemTemp.createTempSync ();
791
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
792
-
793
752
File (path.join (tempDirectory.path, pubspecLockBasename))
794
753
.writeAsStringSync (_validMultiplePubspecLockContent);
795
754
@@ -831,9 +790,6 @@ void main() {
831
790
'when multiple licenses are not allowed' ,
832
791
withRunner (
833
792
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
834
- final tempDirectory = Directory .systemTemp.createTempSync ();
835
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
836
-
837
793
File (path.join (tempDirectory.path, pubspecLockBasename))
838
794
.writeAsStringSync (_validMultiplePubspecLockContent);
839
795
@@ -880,9 +836,6 @@ void main() {
880
836
'warns when a license is not recognized' ,
881
837
withRunner (
882
838
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
883
- final tempDirectory = Directory .systemTemp.createTempSync ();
884
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
885
-
886
839
File (path.join (tempDirectory.path, pubspecLockBasename))
887
840
.writeAsStringSync (_validPubspecLockContent);
888
841
@@ -914,9 +867,6 @@ void main() {
914
867
'exits when a license is forbidden' ,
915
868
withRunner (
916
869
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
917
- final tempDirectory = Directory .systemTemp.createTempSync ();
918
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
919
-
920
870
File (path.join (tempDirectory.path, pubspecLockBasename))
921
871
.writeAsStringSync (_validPubspecLockContent);
922
872
@@ -943,9 +893,6 @@ void main() {
943
893
'when a single license is forbidden' ,
944
894
withRunner (
945
895
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
946
- final tempDirectory = Directory .systemTemp.createTempSync ();
947
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
948
-
949
896
File (path.join (tempDirectory.path, pubspecLockBasename))
950
897
.writeAsStringSync (_validMultiplePubspecLockContent);
951
898
@@ -985,9 +932,6 @@ void main() {
985
932
'when a single license is forbidden and allowed is left empty' ,
986
933
withRunner (
987
934
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
988
- final tempDirectory = Directory .systemTemp.createTempSync ();
989
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
990
-
991
935
File (path.join (tempDirectory.path, pubspecLockBasename))
992
936
.writeAsStringSync (_validMultiplePubspecLockContent);
993
937
@@ -1029,9 +973,6 @@ void main() {
1029
973
'when multiple licenses are forbidden' ,
1030
974
withRunner (
1031
975
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1032
- final tempDirectory = Directory .systemTemp.createTempSync ();
1033
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1034
-
1035
976
File (path.join (tempDirectory.path, pubspecLockBasename))
1036
977
.writeAsStringSync (_validMultiplePubspecLockContent);
1037
978
@@ -1083,9 +1024,6 @@ void main() {
1083
1024
'a single package by name' ,
1084
1025
withRunner (
1085
1026
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1086
- final tempDirectory = Directory .systemTemp.createTempSync ();
1087
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1088
-
1089
1027
File (path.join (tempDirectory.path, pubspecLockBasename))
1090
1028
.writeAsStringSync (_validMultiplePubspecLockContent);
1091
1029
@@ -1118,9 +1056,6 @@ void main() {
1118
1056
'multiple packages by name' ,
1119
1057
withRunner (
1120
1058
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1121
- final tempDirectory = Directory .systemTemp.createTempSync ();
1122
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1123
-
1124
1059
File (path.join (tempDirectory.path, pubspecLockBasename))
1125
1060
.writeAsStringSync (_validMultiplePubspecLockContent);
1126
1061
@@ -1154,9 +1089,6 @@ void main() {
1154
1089
'when it did not find a pubspec.lock file at the target path' ,
1155
1090
withRunner (
1156
1091
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1157
- final tempDirectory = Directory .systemTemp.createTempSync ();
1158
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1159
-
1160
1092
when (() => logger.progress (any ())).thenReturn (progress);
1161
1093
1162
1094
final result = await commandRunner.run (
@@ -1177,9 +1109,6 @@ void main() {
1177
1109
'when it failed to parse a pubspec.lock file at the target path' ,
1178
1110
withRunner (
1179
1111
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1180
- final tempDirectory = Directory .systemTemp.createTempSync ();
1181
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1182
-
1183
1112
File (path.join (tempDirectory.path, pubspecLockBasename))
1184
1113
.writeAsStringSync ('' );
1185
1114
@@ -1203,9 +1132,6 @@ void main() {
1203
1132
'when no dependencies of type are found' ,
1204
1133
withRunner (
1205
1134
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1206
- final tempDirectory = Directory .systemTemp.createTempSync ();
1207
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1208
-
1209
1135
File (path.join (tempDirectory.path, pubspecLockBasename))
1210
1136
.writeAsStringSync (_emptyPubspecLockContent);
1211
1137
@@ -1229,9 +1155,6 @@ void main() {
1229
1155
'when PubLicense throws a PubLicenseException' ,
1230
1156
withRunner (
1231
1157
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1232
- final tempDirectory = Directory .systemTemp.createTempSync ();
1233
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1234
-
1235
1158
File (path.join (tempDirectory.path, pubspecLockBasename))
1236
1159
.writeAsStringSync (_validPubspecLockContent);
1237
1160
@@ -1263,9 +1186,6 @@ void main() {
1263
1186
'when PubLicense throws an unknown error' ,
1264
1187
withRunner (
1265
1188
(commandRunner, logger, pubUpdater, pubLicense, printLogs) async {
1266
- final tempDirectory = Directory .systemTemp.createTempSync ();
1267
- addTearDown (() => tempDirectory.deleteSync (recursive: true ));
1268
-
1269
1189
File (path.join (tempDirectory.path, pubspecLockBasename))
1270
1190
.writeAsStringSync (_validPubspecLockContent);
1271
1191
0 commit comments