-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Redis } from "../redis.ts"; | ||
import { assertEquals } from "../vendor/https/deno.land/std/assert/mod.ts"; | ||
import { | ||
afterAll, | ||
afterEach, | ||
beforeAll, | ||
beforeEach, | ||
describe, | ||
it, | ||
} from "../vendor/https/deno.land/std/testing/bdd.ts"; | ||
import { | ||
newClient, | ||
nextPort, | ||
startRedis, | ||
stopRedis, | ||
TestServer, | ||
} from "./test_util.ts"; | ||
|
||
describe("reconnect", () => { | ||
let port!: number; | ||
beforeAll(() => { | ||
port = nextPort(); | ||
}); | ||
|
||
it("auto reconnect", async () => { | ||
let server = await startRedis({ port }); | ||
const client = await newClient({ hostname: "127.0.0.1", port }); | ||
assertEquals(await client.ping(), "PONG"); | ||
await stopRedis(server); | ||
server = await startRedis({ port }); | ||
assertEquals(await client.ping(), "PONG"); | ||
client.close(); | ||
await stopRedis(server); | ||
}); | ||
|
||
it("auto reconnect, with db spec", async () => { | ||
let server = await startRedis({ port }); | ||
const client = await newClient({ hostname: "127.0.0.1", port, db: 1 }); | ||
assertEquals(await client.ping(), "PONG"); | ||
await stopRedis(server); | ||
server = await startRedis({ port }); | ||
assertEquals(await client.ping(), "PONG"); //never resolve | ||
client.close(); | ||
await stopRedis(server); | ||
}); | ||
}); |