Skip to content

Instantly share code, notes, and snippets.

@jhoerr
Created April 5, 2018 16:33
Show Gist options
  • Save jhoerr/389a052c8d092c1e0e12c675e830de3d to your computer and use it in GitHub Desktop.
Save jhoerr/389a052c8d092c1e0e12c675e830de3d to your computer and use it in GitHub Desktop.
import * as redis from "redis";
import * as util from "util";
describe("Redis cache", () => {
const port = 6379;
const host = "iubot-test.redis-test.uits.iu.edu";
const token = "...TOKEN...";
const client = redis.createClient({
host: host,
port: port,
password: token,
tls: {
servername: host,
checkServerIdentity(servername, cert) {
return undefined;
}
}
});
it("should ping the server successfully", async () => {
const ping = util.promisify(client.ping).bind(client);
const actual = await ping();
expect(actual).toBe("PONG");
});
it("should set/get a value", async () => {
const get = util.promisify(client.get).bind(client);
const set = util.promisify(client.set).bind(client);
await set("pug", "cute");
const actual = await get("pug");
expect(actual).toBe("cute");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment