@@ -17,15 +17,61 @@ ValidatorCreator size(int size) {
17
17
return (entrypoint) => new SizeValidator (entrypoint, new Future .value (size));
18
18
}
19
19
20
+ expectSizeValidationError (ValidatorCreator fn, Matcher matcher) {
21
+ expect (validatePackage (fn), completion (pairOf (contains (matcher), anything)));
22
+ }
23
+
20
24
main () {
21
- setUp (d.validPackage.create);
25
+ test ('considers a package valid if it is <= 100 MB' , () async {
26
+ await d.validPackage.create ();
22
27
23
- test ('considers a package valid if it is <= 100 MB' , () {
24
28
expectNoValidationError (size (100 ));
25
29
expectNoValidationError (size (100 * math.pow (2 , 20 )));
26
30
});
27
31
28
- test ('considers a package invalid if it is more than 100 MB' , () {
29
- expectValidationError (size (100 * math.pow (2 , 20 ) + 1 ));
32
+ group ('considers a package invalid if it is more than 100 MB' , () {
33
+ test ('package is not under source control and no .gitignore exists' ,
34
+ () async {
35
+ await d.validPackage.create ();
36
+
37
+ expectSizeValidationError (
38
+ size (100 * math.pow (2 , 20 ) + 1 ),
39
+ equals ("Your package is 100.0 MB. Hosted packages must "
40
+ "be smaller than 100 MB." ));
41
+ });
42
+
43
+ test ('package is not under source control and .gitignore exists' , () async {
44
+ await d.validPackage.create ();
45
+ await d.dir (appPath, [d.file ('.gitignore' , 'ignored' )]).create ();
46
+
47
+ expectSizeValidationError (
48
+ size (100 * math.pow (2 , 20 ) + 1 ),
49
+ allOf (
50
+ contains ("Hosted packages must be smaller than 100 MB." ),
51
+ contains ("Your .gitignore has no effect since your project "
52
+ "does not appear to be in version control." )));
53
+ });
54
+
55
+ test ('package is under source control and no .gitignore exists' , () async {
56
+ await d.validPackage.create ();
57
+ await d.git (appPath).create ();
58
+
59
+ expectSizeValidationError (
60
+ size (100 * math.pow (2 , 20 ) + 1 ),
61
+ allOf (
62
+ contains ("Hosted packages must be smaller than 100 MB." ),
63
+ contains ("Consider adding a .gitignore to avoid including "
64
+ "temporary files." )));
65
+ });
66
+
67
+ test ('package is under source control and .gitignore exists' , () async {
68
+ await d.validPackage.create ();
69
+ await d.git (appPath, [d.file ('.gitignore' , 'ignored' )]).create ();
70
+
71
+ expectSizeValidationError (
72
+ size (100 * math.pow (2 , 20 ) + 1 ),
73
+ equals ("Your package is 100.0 MB. Hosted packages must "
74
+ "be smaller than 100 MB." ));
75
+ });
30
76
});
31
77
}
0 commit comments