Use redis testcontainer
This commit is contained in:
parent
b774987e61
commit
60f82610f6
|
@ -1,8 +1,26 @@
|
||||||
|
import { GenericContainer, StartedTestContainer } from "testcontainers"
|
||||||
import { generator, structures } from "../../../tests"
|
import { generator, structures } from "../../../tests"
|
||||||
import RedisWrapper from "../redis"
|
import RedisWrapper from "../redis"
|
||||||
|
import { env } from "../.."
|
||||||
|
|
||||||
describe("redis", () => {
|
describe("redis", () => {
|
||||||
let redis: RedisWrapper
|
let redis: RedisWrapper
|
||||||
|
let container: StartedTestContainer
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const container = await new GenericContainer("redis")
|
||||||
|
.withExposedPorts(6379)
|
||||||
|
.start()
|
||||||
|
|
||||||
|
env._set(
|
||||||
|
"REDIS_URL",
|
||||||
|
`${container.getHost()}:${container.getMappedPort(6379)}`
|
||||||
|
)
|
||||||
|
env._set("MOCK_REDIS", 0)
|
||||||
|
env._set("REDIS_PASSWORD", 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(() => container?.stop())
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
redis = new RedisWrapper(structures.db.id())
|
redis = new RedisWrapper(structures.db.id())
|
||||||
|
@ -165,7 +183,7 @@ describe("redis", () => {
|
||||||
await redis.store(key, value)
|
await redis.store(key, value)
|
||||||
|
|
||||||
await expect(redis.increment(key)).rejects.toThrowError(
|
await expect(redis.increment(key)).rejects.toThrowError(
|
||||||
`Redis ${key} does not contains a number`
|
"ERR value is not an integer or out of range"
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue