use minio image instead of s3 for testing

This commit is contained in:
Peter Clement 2024-03-15 16:03:34 +00:00
parent b1ec5826ec
commit 0e81191b5a
3 changed files with 9 additions and 8 deletions

View File

@ -28,7 +28,7 @@ jest.mock("uuid", () => ({ v4: () => "00000000-0000-0000-0000-000000000000" }))
import { default as RestIntegration } from "../rest" import { default as RestIntegration } from "../rest"
import { RestAuthType } from "@budibase/types" import { RestAuthType } from "@budibase/types"
import fetch from "node-fetch" import fetch from "node-fetch"
import { databaseTestProviders } from "./utils" import { objectStoreTestProviders } from "./utils"
const FormData = require("form-data") const FormData = require("form-data")
const { URLSearchParams } = require("url") const { URLSearchParams } = require("url")
@ -627,11 +627,11 @@ describe("REST Integration", () => {
describe("File Handling", () => { describe("File Handling", () => {
beforeAll(async () => { beforeAll(async () => {
await databaseTestProviders.s3.start() await objectStoreTestProviders.minio.start()
}) })
afterAll(async () => { afterAll(async () => {
await databaseTestProviders.s3.stop() await objectStoreTestProviders.minio.stop()
}) })
it("uploads file to object store and returns signed URL", async () => { it("uploads file to object store and returns signed URL", async () => {

View File

@ -4,7 +4,7 @@ import { Datasource } from "@budibase/types"
import * as postgres from "./postgres" import * as postgres from "./postgres"
import * as mongodb from "./mongodb" import * as mongodb from "./mongodb"
import * as mysql from "./mysql" import * as mysql from "./mysql"
import * as s3 from "./s3" import * as minio from "./minio"
import { StartedTestContainer } from "testcontainers" import { StartedTestContainer } from "testcontainers"
jest.setTimeout(30000) jest.setTimeout(30000)
@ -15,4 +15,6 @@ export interface DatabaseProvider {
datasource(): Promise<Datasource> datasource(): Promise<Datasource>
} }
export const databaseTestProviders = { postgres, mongodb, mysql, s3 } export const databaseTestProviders = { postgres, mongodb, mysql }
export const objectStoreTestProviders = { minio }

View File

@ -1,10 +1,9 @@
import { Datasource } from "@budibase/types"
import { GenericContainer, Wait, StartedTestContainer } from "testcontainers" import { GenericContainer, Wait, StartedTestContainer } from "testcontainers"
import { AbstractWaitStrategy } from "testcontainers/build/wait-strategies/wait-strategy" import { AbstractWaitStrategy } from "testcontainers/build/wait-strategies/wait-strategy"
let container: StartedTestContainer | undefined let container: StartedTestContainer | undefined
class MinioWaitStrategy extends AbstractWaitStrategy { class ObjectStoreWaitStrategy extends AbstractWaitStrategy {
async waitUntilReady(container: any, boundPorts: any, startTime?: Date) { async waitUntilReady(container: any, boundPorts: any, startTime?: Date) {
const logs = Wait.forListeningPorts() const logs = Wait.forListeningPorts()
await logs.waitUntilReady(container, boundPorts, startTime) await logs.waitUntilReady(container, boundPorts, startTime)
@ -19,7 +18,7 @@ export async function start(): Promise<StartedTestContainer> {
MINIO_ACCESS_KEY: "budibase", MINIO_ACCESS_KEY: "budibase",
MINIO_SECRET_KEY: "budibase", MINIO_SECRET_KEY: "budibase",
}) })
.withWaitStrategy(new MinioWaitStrategy().withStartupTimeout(30000)) .withWaitStrategy(new ObjectStoreWaitStrategy().withStartupTimeout(30000))
.start() .start()
return container return container