44
55import 'package:_pub_shared/data/account_api.dart' ;
66import 'package:_pub_shared/data/admin_api.dart' ;
7+ import 'package:clock/clock.dart' ;
78import 'package:pub_dev/admin/backend.dart' ;
89import 'package:pub_dev/admin/models.dart' ;
910import 'package:pub_dev/shared/datastore.dart' ;
@@ -71,6 +72,15 @@ void main() {
7172 return mc! .status! ;
7273 }
7374
75+ Future <void > _verifyCaseExistence (String caseId, bool exists) async {
76+ final mc = await adminBackend.lookupModerationCase (caseId);
77+ if (exists) {
78+ expect (mc, isNotNull);
79+ } else {
80+ expect (mc, isNull);
81+ }
82+ }
83+
7484 testWithProfile ('notification: no action' , fn: () async {
7585 final mc = await _prepare (apply: null );
7686 expect (await _close (mc.caseId), 'no-action' );
@@ -82,13 +92,28 @@ void main() {
8292 'SHOUT Deleting object from public bucket: "packages/oxygen-2.0.0-dev.tar.gz".' ,
8393 ], fn: () async {
8494 final mc = await _prepare (apply: true );
95+
96+ // cleanup doesn't remove case prematurely
97+ await _verifyCaseExistence (mc.caseId, true );
98+ await adminBackend.deleteModerationCases ();
99+ await _verifyCaseExistence (mc.caseId, true );
100+
101+ // close case
85102 expect (
86103 await _close (
87104 mc.caseId,
88105 reason: 'The package violated our policy.' ,
89106 ),
90107 'moderation-applied' ,
91108 );
109+
110+ // cleanup does remove case after the threshold is reached
111+ await _verifyCaseExistence (mc.caseId, true );
112+ final futureClock = Clock .fixed (clock.now ().add (Duration (days: 365 * 3 )));
113+ await withClock (futureClock, () async {
114+ await adminBackend.deleteModerationCases ();
115+ });
116+ await _verifyCaseExistence (mc.caseId, false );
92117 });
93118
94119 testWithProfile ('appeal no action: revert' , expectedLogMessages: [
0 commit comments