1
0
Fork 0
mirror of synced 2024-09-11 06:56:23 +12:00

Stop container after tests

This commit is contained in:
Adria Navarro 2023-02-06 19:49:30 +00:00
parent 4908cc5387
commit 71199c06ec

View file

@ -15,7 +15,7 @@ import {
import _ from "lodash" import _ from "lodash"
import { generator } from "@budibase/backend-core/tests" import { generator } from "@budibase/backend-core/tests"
import { utils } from "@budibase/backend-core" import { utils } from "@budibase/backend-core"
import { GenericContainer } from "testcontainers" import { GenericContainer, StartedTestContainer } from "testcontainers"
const config = setup.getConfig()! const config = setup.getConfig()!
@ -30,14 +30,16 @@ describe("row api - postgres", () => {
let host: string let host: string
let port: number let port: number
let postgresContainer: StartedTestContainer
beforeAll(async () => { beforeAll(async () => {
const container = await new GenericContainer("postgres") postgresContainer = await new GenericContainer("postgres")
.withExposedPorts(5432) .withExposedPorts(5432)
.withEnv("POSTGRES_PASSWORD", "password") .withEnv("POSTGRES_PASSWORD", "password")
.start() .start()
host = container.getContainerIpAddress() host = postgresContainer.getContainerIpAddress()
port = container.getMappedPort(5432) port = postgresContainer.getMappedPort(5432)
await config.init() await config.init()
const apiKey = await config.generateApiKey() const apiKey = await config.generateApiKey()
@ -132,6 +134,7 @@ describe("row api - postgres", () => {
}) })
afterAll(async () => { afterAll(async () => {
await postgresContainer?.stop()
await config.end() await config.end()
}) })