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