Skip to content

Commit f4f47ae

Browse files
DifferentialOrangeoleg-jukovec
authored andcommitted
code health: reuse Retry in test helpers
Part of #214
1 parent b0956f3 commit f4f47ae

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

test_helpers/utils.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,16 @@ 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)
61-
}
62-
63-
return false
59+
return err == nil
6460
}
6561

6662
func SkipIfSQLUnsupported(t testing.TB) {

0 commit comments

Comments
 (0)