Skip to content

Commit d9fc367

Browse files
authored
Update request timeout exceeded test (#21)
Fix testing request timeout in cluster tests to evaluate an error code instead of expecting an exception. Signed-off-by: James Duong <[email protected]>
1 parent bd4fce4 commit d9fc367

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tests/ValkeyGlideClusterFeaturesTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,15 @@ public function testConstructorWithRequestTimeoutExceeded()
217217
10 // 10 millisecond timeout
218218
);
219219

220-
try {
221-
$valkey_glide->rawcommand(['type' => 'primarySlotKey', 'key' => 'test'], "DEBUG", "SLEEP", "2");
222-
$this->fail("Should have thrown a timeout exception.");
223-
} catch (Exception $e) {
224-
$this->assertStringContains("timed out", $e->getMessage(), "Exception should indicate authentication failure");
225-
} finally {
226-
// Sleep the test runner so that the server can finish the sleep command.
227-
sleep(2);
228-
// Clean up
229-
$valkey_glide?->close();
230-
}
220+
$res = $valkey_glide->rawcommand(['type' => 'primarySlotKey', 'key' => 'test'], "DEBUG", "SLEEP", "2");
221+
222+
// Sleep the test runner so that the server can finish the sleep command.
223+
sleep(2);
224+
// Clean up
225+
$valkey_glide?->close();
226+
227+
// Now evaluate the result of the DEBUG command (should have failed due to timeout).
228+
$this->assertFalse($res);
231229
}
232230

233231
public function testConstructorWithLongTimeout()

0 commit comments

Comments
 (0)