Skip to content

Commit

Permalink
fix: forgot to add utils.go
Browse files Browse the repository at this point in the history
  • Loading branch information
romanzac committed Apr 2, 2024
1 parent def82f2 commit 3b571ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,22 @@ func GenerateRandomSQLInsert(maxLength int) (string, error) {
return query, nil
}

func WaitForMsg(t *testing.T, wg *sync.WaitGroup, ch chan *protocol.Envelope) {
wg.Add(1)
log := utils.Logger()
go func() {
defer wg.Done()
select {
case env := <-ch:
msg := env.Message()
log.Info("Received ", zap.String("msg", msg.String()))
case <-time.After(2 * time.Second):
require.Fail(t, "Message timeout")
}
}()
wg.Wait()
}

func WaitForTimeout(t *testing.T, ctx context.Context, wg *sync.WaitGroup, ch chan *protocol.Envelope) {
wg.Add(1)
go func() {
Expand Down

0 comments on commit 3b571ba

Please sign in to comment.