File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed 
internal/server/evaluation/client Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -231,23 +231,22 @@ func TestServer_EvaluationSnapshotNamespaceStream_ContextCancel(t *testing.T) {
231231		ch  :=  args .Get (2 ).(chan <-  * rpcevaluation.EvaluationNamespaceSnapshot )
232232		go  func () {
233233			ch  <-  & rpcevaluation.EvaluationNamespaceSnapshot {Digest : "d1" }
234- 			// simulate context cancel before next send  
235- 			wait   <-   struct {}{} 
234+ 			// wait for Send to be called before closing  
235+ 			<- wait 
236236			close (ch )
237237		}()
238238	})
239239
240240	ctx , cancel  :=  context .WithCancel (t .Context ())
241241	stream  :=  & mockStream {ctx : ctx }
242- 	stream .On ("Send" , mock .Anything ).Return (nil )
242+ 	stream .On ("Send" , mock .Anything ).Return (nil ).Run (func (args  mock.Arguments ) {
243+ 		// signal that Send was called, then cancel context 
244+ 		wait  <-  struct {}{}
245+ 		cancel ()
246+ 	})
243247	s  :=  NewServer (logger , envStore )
244248	req  :=  & rpcevaluation.EvaluationNamespaceSnapshotStreamRequest {EnvironmentKey : "env-key" , Key : "ns-key" }
245249
246- 	go  func () {
247- 		<- wait 
248- 		cancel ()
249- 	}()
250- 
251250	err  :=  s .EvaluationSnapshotNamespaceStream (req , stream )
252251	require .NoError (t , err )
253252	require .GreaterOrEqual (t , len (stream .sent ), 1 )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments