Skip to content

Commit 5f81bea

Browse files
code health: reuse Retry in test helpers
Part of #214
1 parent 7665568 commit 5f81bea

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test_helpers/utils.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ func DeleteRecordByKey(t *testing.T, conn tarantool.Connector,
4747
// Returns false in case of connection is not in the connected state
4848
// after specified retries count, true otherwise.
4949
func WaitUntilReconnected(conn *tarantool.Connection, retries uint, timeout time.Duration) bool {
50-
for i := uint(0); ; i++ {
50+
err := Retry(func(arg interface{}) error {
51+
conn := arg.(*tarantool.Connection)
5152
connected := conn.ConnectedNow()
52-
if connected {
53-
return true
53+
if !connected {
54+
return fmt.Errorf("not connected")
5455
}
56+
return nil
57+
}, conn, int(retries), timeout)
5558

56-
if i == retries {
57-
break
58-
}
59-
60-
time.Sleep(timeout)
59+
if err != nil {
60+
return false
6161
}
6262

63-
return false
63+
return true
6464
}
6565

6666
func SkipIfSQLUnsupported(t testing.TB) {

0 commit comments

Comments
 (0)