File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Tests/PowerSync/PowerSync.Common.Tests/Client Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1035,4 +1035,36 @@ public async Task OnChange_ThrottleCancelledCleanly()
10351035
10361036 Assert . True ( await tcs . Task ) ;
10371037 }
1038+
1039+ [ Fact ]
1040+ public async Task Watch_SingleEventForBatchedQuery ( )
1041+ {
1042+ int eventCount = 0 ;
1043+ long lastCount = 0 ;
1044+ var tcs = new TaskCompletionSource < bool > ( ) ;
1045+
1046+ var listener = db . Watch < CountResult > (
1047+ "select count(*) as count from assets" ,
1048+ null ,
1049+ new ( ) { Signal = testCts . Token } ) ;
1050+
1051+ _ = Task . Run ( async ( ) =>
1052+ {
1053+ await foreach ( var rows in listener )
1054+ {
1055+ lastCount = rows [ 0 ] . count ;
1056+ Interlocked . Increment ( ref eventCount ) ;
1057+ }
1058+ tcs . TrySetResult ( true ) ;
1059+ } ) ;
1060+
1061+ // Long batched query
1062+ const int QUERY_COUNT = 10000 ;
1063+ await TestUtils . InsertRandomAssets ( db , QUERY_COUNT ) ;
1064+
1065+ testCts . Cancel ( ) ;
1066+ Assert . True ( await tcs . Task ) ;
1067+ Assert . Equal ( 1 , eventCount ) ;
1068+ Assert . Equal ( QUERY_COUNT , lastCount ) ;
1069+ }
10381070}
You can’t perform that action at this time.
0 commit comments