Skip to content

Commit

Permalink
Use require.Eventually
Browse files Browse the repository at this point in the history
  • Loading branch information
Demogorgon314 committed Jan 3, 2023
1 parent 0f46c22 commit 83d8e66
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pulsar/table_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package pulsar
import (
"context"
"fmt"
"github.com/stretchr/testify/require"
"reflect"
"testing"
"time"
Expand Down Expand Up @@ -114,9 +115,9 @@ func TestPublishNilValue(t *testing.T) {
})
assert.NoError(t, err)

for tv.Size() < 1 {
time.Sleep(time.Second * 1)
}
require.Eventually(t, func() bool {
return tv.Size() == 1
}, 5*time.Second, 100*time.Millisecond)

assert.Equal(t, *(tv.Get("key-1").(*string)), "value-1")

Expand All @@ -126,19 +127,19 @@ func TestPublishNilValue(t *testing.T) {
})
assert.NoError(t, err)

for tv.Size() >= 1 {
time.Sleep(time.Second * 1)
}
require.Eventually(t, func() bool {
return tv.Size() == 0
}, 5*time.Second, 100*time.Millisecond)

_, err = producer.Send(context.Background(), &ProducerMessage{
Key: "key-2",
Value: "value-2",
})
assert.NoError(t, err)

for tv.Size() < 1 {
time.Sleep(time.Second * 1)
}
require.Eventually(t, func() bool {
return tv.Size() == 1
}, 5*time.Second, 100*time.Millisecond)

assert.Equal(t, *(tv.Get("key-2").(*string)), "value-2")
}

0 comments on commit 83d8e66

Please sign in to comment.