1
0
Fork 0
mirror of synced 2024-06-13 07:54:46 +12:00
budibase/qa-core/src/integrations/validators/arango.integration.spec.ts

78 lines
2.2 KiB
TypeScript
Raw Normal View History

2023-05-12 21:17:14 +12:00
import { GenericContainer, Wait } from "testcontainers"
import arangodb from "../../../../packages/server/src/integrations/arangodb"
import { generator } from "../../shared"
jest.unmock("arangojs")
describe("datasource validators", () => {
describe("arangodb", () => {
let connectionSettings: {
user: string
password: string
url: string
}
beforeAll(async () => {
const user = "root"
const password = generator.hash()
const container = await new GenericContainer("arangodb")
.withExposedPorts(8529)
.withEnv("ARANGO_ROOT_PASSWORD", password)
.withWaitStrategy(
Wait.forLogMessage("is ready for business. Have fun!")
)
.start()
connectionSettings = {
user,
password,
url: `http://${container.getContainerIpAddress()}:${container.getMappedPort(
8529
)}`,
}
})
it("test valid connection string", async () => {
const integration = new arangodb.integration({
2023-05-12 21:17:14 +12:00
url: connectionSettings.url,
username: connectionSettings.user,
password: connectionSettings.password,
databaseName: "",
collection: "",
})
const result = await integration.testConnection()
2023-05-17 19:57:43 +12:00
expect(result).toEqual({ connected: true })
2023-05-12 21:17:14 +12:00
})
2023-05-12 21:23:51 +12:00
it("test wrong password", async () => {
const integration = new arangodb.integration({
2023-05-12 21:23:51 +12:00
url: connectionSettings.url,
username: connectionSettings.user,
password: "wrong",
databaseName: "",
collection: "",
})
const result = await integration.testConnection()
2023-05-12 21:23:51 +12:00
expect(result).toEqual({
2023-05-17 19:57:43 +12:00
connected: false,
2023-05-12 21:23:51 +12:00
error: "not authorized to execute this request",
})
})
it("test wrong url", async () => {
const integration = new arangodb.integration({
2023-05-12 21:23:51 +12:00
url: "http://not.here",
username: connectionSettings.user,
password: connectionSettings.password,
databaseName: "",
collection: "",
})
const result = await integration.testConnection()
2023-05-12 21:23:51 +12:00
expect(result).toEqual({
2023-05-17 19:57:43 +12:00
connected: false,
2023-05-12 21:23:51 +12:00
error: "getaddrinfo ENOTFOUND not.here",
})
})
2023-05-12 21:17:14 +12:00
})
})