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 d1b4837
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pulsar/table_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestTableView(t *testing.T) {
Expand Down Expand Up @@ -114,31 +115,31 @@ 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")

// Send nil value
// send nil value
_, err = producer.Send(context.Background(), &ProducerMessage{
Key: "key-1",
})
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 d1b4837

Please sign in to comment.