Merge pull request #10619 from Budibase/budi-6932/fix_tests

Update tests to check new interfaces
This commit is contained in:
Adria Navarro 2023-05-17 10:14:39 +02:00 committed by GitHub
commit d38aab942a
9 changed files with 36 additions and 15 deletions

View File

@ -41,7 +41,7 @@ describe("datasource validators", () => {
collection: "", collection: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test wrong password", async () => { it("test wrong password", async () => {
@ -54,6 +54,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: "not authorized to execute this request", error: "not authorized to execute this request",
}) })
}) })
@ -68,6 +69,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: "getaddrinfo ENOTFOUND not.here", error: "getaddrinfo ENOTFOUND not.here",
}) })
}) })

View File

@ -1,7 +1,7 @@
import { GenericContainer } from "testcontainers" import { GenericContainer } from "testcontainers"
import { generator } from "@budibase/backend-core/tests"
import couchdb from "../../../../packages/server/src/integrations/couchdb" import couchdb from "../../../../packages/server/src/integrations/couchdb"
import { generator } from "../../shared"
describe("datasource validators", () => { describe("datasource validators", () => {
describe("couchdb", () => { describe("couchdb", () => {
@ -37,7 +37,7 @@ describe("datasource validators", () => {
database: "db", database: "db",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid database", async () => { it("test invalid database", async () => {
@ -46,7 +46,9 @@ describe("datasource validators", () => {
database: "random_db", database: "random_db",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(false) expect(result).toEqual({
connected: false,
})
}) })
it("test invalid url", async () => { it("test invalid url", async () => {
@ -56,6 +58,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: error:
"request to http://invalid:123/any failed, reason: getaddrinfo ENOTFOUND invalid", "request to http://invalid:123/any failed, reason: getaddrinfo ENOTFOUND invalid",
}) })

View File

@ -41,7 +41,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test wrong endpoint", async () => { it("test wrong endpoint", async () => {
@ -54,6 +54,7 @@ describe("datasource validators", () => {
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: error:
"Inaccessible host: `wrong.url' at port `undefined'. This service may not be available in the `eu-west-1' region.", "Inaccessible host: `wrong.url' at port `undefined'. This service may not be available in the `eu-west-1' region.",
}) })

View File

@ -49,7 +49,7 @@ describe("datasource validators", () => {
tlsCAFile: "", tlsCAFile: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid password", async () => { it("test invalid password", async () => {
@ -61,7 +61,10 @@ describe("datasource validators", () => {
tlsCAFile: "", tlsCAFile: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ error: "Authentication failed." }) expect(result).toEqual({
connected: false,
error: "Authentication failed.",
})
}) })
it("test invalid username", async () => { it("test invalid username", async () => {
@ -73,7 +76,10 @@ describe("datasource validators", () => {
tlsCAFile: "", tlsCAFile: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ error: "Authentication failed." }) expect(result).toEqual({
connected: false,
error: "Authentication failed.",
})
}) })
it("test invalid connection", async () => { it("test invalid connection", async () => {
@ -85,7 +91,10 @@ describe("datasource validators", () => {
tlsCAFile: "", tlsCAFile: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ error: "Error: getaddrinfo ENOTFOUND http" }) expect(result).toEqual({
connected: false,
error: "Error: getaddrinfo ENOTFOUND http",
})
}) })
}) })
}) })

View File

@ -43,7 +43,7 @@ describe("datasource validators", () => {
schema: "dbo", schema: "dbo",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid password", async () => { it("test invalid password", async () => {
@ -57,6 +57,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: "ConnectionError: Login failed for user 'sa'.", error: "ConnectionError: Login failed for user 'sa'.",
}) })
}) })

View File

@ -31,7 +31,7 @@ describe("datasource validators", () => {
rejectUnauthorized: true, rejectUnauthorized: true,
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid database", async () => { it("test invalid database", async () => {
@ -45,6 +45,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: "Access denied for user 'user'@'%' to database 'test'", error: "Access denied for user 'user'@'%' to database 'test'",
}) })
}) })
@ -60,6 +61,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: error:
"Access denied for user 'root'@'172.17.0.1' (using password: YES)", "Access denied for user 'root'@'172.17.0.1' (using password: YES)",
}) })

View File

@ -30,7 +30,7 @@ describe("datasource validators", () => {
rejectUnauthorized: false, rejectUnauthorized: false,
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid connection string", async () => { it("test invalid connection string", async () => {
@ -46,6 +46,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: 'password authentication failed for user "wrong"', error: 'password authentication failed for user "wrong"',
}) })
}) })

View File

@ -24,7 +24,7 @@ describe("datasource validators", () => {
username: "", username: "",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test invalid connection even with wrong user/password", async () => { it("test invalid connection even with wrong user/password", async () => {
@ -36,6 +36,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: error:
"WRONGPASS invalid username-password pair or user is disabled.", "WRONGPASS invalid username-password pair or user is disabled.",
}) })
@ -64,7 +65,7 @@ describe("datasource validators", () => {
password: "P@ssW0rd!", password: "P@ssW0rd!",
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
}) })
}) })

View File

@ -30,7 +30,7 @@ describe("datasource validators", () => {
endpoint: `http://${host}:${port}`, endpoint: `http://${host}:${port}`,
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toBe(true) expect(result).toEqual({ connected: true })
}) })
it("test wrong endpoint", async () => { it("test wrong endpoint", async () => {
@ -43,6 +43,7 @@ describe("datasource validators", () => {
}) })
const result = await integration.testConnection() const result = await integration.testConnection()
expect(result).toEqual({ expect(result).toEqual({
connected: false,
error: error:
"Inaccessible host: `wrong' at port `undefined'. This service may not be available in the `eu-west-2' region.", "Inaccessible host: `wrong' at port `undefined'. This service may not be available in the `eu-west-2' region.",
}) })