@ -33,9 +33,13 @@ func TestStore_Get(t *testing.T) {
newEventServiceHealthRegister ( 22 , 2 , "srv1" ) )
newEventServiceHealthRegister ( 22 , 2 , "srv1" ) )
runStep ( t , "from empty store, starts materializer" , func ( t * testing . T ) {
runStep ( t , "from empty store, starts materializer" , func ( t * testing . T ) {
result , err := store . Get ( ctx , req )
var result Result
require . NoError ( t , err )
retry . Run ( t , func ( r * retry . R ) {
require . Equal ( t , uint64 ( 22 ) , result . Index )
var err error
result , err = store . Get ( ctx , req )
require . NoError ( r , err )
require . Equal ( r , uint64 ( 22 ) , result . Index )
} )
r , ok := result . Value . ( fakeResult )
r , ok := result . Value . ( fakeResult )
require . True ( t , ok )
require . True ( t , ok )
@ -240,15 +244,17 @@ func TestStore_Notify(t *testing.T) {
} )
} )
runStep ( t , "updates are received" , func ( t * testing . T ) {
runStep ( t , "updates are received" , func ( t * testing . T ) {
select {
retry . Run ( t , func ( r * retry . R ) {
case update := <- ch :
select {
require . NoError ( t , update . Err )
case update := <- ch :
require . Equal ( t , cID , update . CorrelationID )
require . NoError ( r , update . Err )
require . Equal ( t , uint64 ( 22 ) , update . Meta . Index )
require . Equal ( r , cID , update . CorrelationID )
require . Equal ( t , uint64 ( 22 ) , update . Result . ( fakeResult ) . index )
require . Equal ( r , uint64 ( 22 ) , update . Meta . Index )
case <- time . After ( 100 * time . Millisecond ) :
require . Equal ( r , uint64 ( 22 ) , update . Result . ( fakeResult ) . index )
t . Fatalf ( "expected Get to unblock when new events are received" )
case <- time . After ( 100 * time . Millisecond ) :
}
r . Stop ( fmt . Errorf ( "expected Get to unblock when new events are received" ) )
}
} )
req . client . QueueEvents ( newEventServiceHealthRegister ( 24 , 2 , "srv1" ) )
req . client . QueueEvents ( newEventServiceHealthRegister ( 24 , 2 , "srv1" ) )