@@ -175,6 +175,7 @@ void main() {
175175
176176 var [stored] = db.select ('SELECT * FROM ps_stream_subscriptions' );
177177 expect (stored, containsPair ('is_default' , 1 ));
178+ expect (stored, containsPair ('ttl' , isNull));
178179
179180 control (
180181 'subscriptions' ,
@@ -185,7 +186,29 @@ void main() {
185186
186187 [stored] = db.select ('SELECT * FROM ps_stream_subscriptions' );
187188 expect (stored, containsPair ('active' , 1 ));
189+ // It's still a default stream, but it now has a TTL to indicate the
190+ // explicit subscription.
191+ expect (stored, containsPair ('is_default' , 1 ));
192+ expect (stored, containsPair ('ttl' , isNotNull));
193+
194+ // Remove the stream from the checkpoint, should still be included due to
195+ // the explicit subscription.
196+ control (
197+ 'line_text' ,
198+ json.encode (
199+ checkpoint (
200+ lastOpId: 1 ,
201+ buckets: [
202+ bucketDescription ('a' , priority: 1 ),
203+ ],
204+ ),
205+ ),
206+ );
207+
208+ [stored] = db.select ('SELECT * FROM ps_stream_subscriptions' );
209+ expect (stored, containsPair ('active' , 0 ));
188210 expect (stored, containsPair ('is_default' , 0 ));
211+ expect (stored, containsPair ('ttl' , isNotNull));
189212 });
190213 });
191214
@@ -318,5 +341,57 @@ void main() {
318341 ),
319342 );
320343 });
344+
345+ syncTest ('can be made implicit' , (_) {
346+ control (
347+ 'subscriptions' ,
348+ json.encode ({
349+ 'subscribe' : {'stream' : 'a' }
350+ }));
351+ control ('start' , null );
352+ control (
353+ 'line_text' ,
354+ json.encode (
355+ checkpoint (
356+ lastOpId: 1 ,
357+ buckets: [],
358+ streams: [('a' , true )],
359+ ),
360+ ),
361+ );
362+
363+ var [stored] = db.select ('SELECT * FROM ps_stream_subscriptions' );
364+ expect (stored, containsPair ('is_default' , 1 ));
365+ expect (stored, containsPair ('ttl' , isNotNull));
366+
367+ control (
368+ 'subscriptions' ,
369+ json.encode ({
370+ 'unsubscribe' : {'stream' : 'a' , 'immediate' : false }
371+ }),
372+ );
373+ control ('stop' , null );
374+
375+ // The stream should no longer be requested
376+ var startInstructions = control ('start' , null );
377+ expect (
378+ startInstructions,
379+ contains (
380+ containsPair (
381+ 'EstablishSyncStream' ,
382+ containsPair (
383+ 'request' ,
384+ containsPair (
385+ 'streams' ,
386+ {
387+ 'include_defaults' : true ,
388+ 'subscriptions' : isEmpty,
389+ },
390+ ),
391+ ),
392+ ),
393+ ),
394+ );
395+ });
321396 });
322397}
0 commit comments