Add useRealQueues helpers

This commit is contained in:
Adria Navarro 2024-11-07 10:28:24 +01:00
parent c5da1a06c6
commit a7bb89a710
1 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,26 @@
import { Queue } from "bull"
import { GenericContainer, Wait } from "testcontainers"
export async function useRealQueues() {
const redis = await new GenericContainer("redis")
.withExposedPorts(6379)
.withEnvironment({})
.withLabels({ "com.budibase": "true" })
.withReuse()
.withWaitStrategy(
Wait.forSuccessfulCommand(
`until redis-cli ping | grep -q PONG; do
echo "Waiting for Redis to be ready..."
sleep 1
done
echo "Redis is ready!"`
).withStartupTimeout(10000)
)
.start()
const port = redis.getMappedPort(6379)
process.env.BULL_TEST_REDIS = `http://127.0.0.1:${port}`
}
export async function processMessages(queue: Queue) {
do {