@@ -17,15 +17,56 @@ ValidatorCreator size(int size) {
1717 return (entrypoint) => new SizeValidator (entrypoint, new Future .value (size));
1818}
1919
20+ expectSizeValidationError (Matcher matcher) {
21+ expect (validatePackage (size (100 * math.pow (2 , 20 ) + 1 )),
22+ completion (pairOf (contains (matcher), anything)));
23+ }
24+
2025main () {
21- setUp (d.validPackage.create);
26+ test ('considers a package valid if it is <= 100 MB' , () async {
27+ await d.validPackage.create ();
2228
23- test ('considers a package valid if it is <= 100 MB' , () {
2429 expectNoValidationError (size (100 ));
2530 expectNoValidationError (size (100 * math.pow (2 , 20 )));
2631 });
2732
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+ });
3071 });
3172}
0 commit comments