mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 21:05:59 +00:00
SYNC: mutli-sql tests
This commit is contained in:
committed by
Diflow
parent
5b246fe44c
commit
afcb226111
7
e2e-tests/.localconfig.js
Normal file
7
e2e-tests/.localconfig.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
mysql: true,
|
||||
postgres: true,
|
||||
mssql: true,
|
||||
// oracle: true,
|
||||
sqlite: true,
|
||||
};
|
||||
@@ -1,3 +1,5 @@
|
||||
const localconfig = require('../../.localconfig');
|
||||
|
||||
Cypress.on('uncaught:exception', (err, runnable) => {
|
||||
// if the error message matches the one about WorkerGlobalScope importScripts
|
||||
if (err.message.includes("Failed to execute 'importScripts' on 'WorkerGlobalScope'")) {
|
||||
@@ -13,8 +15,18 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
function multiTest(testName, testDefinition) {
|
||||
it(testName + ' MySQL', () => testDefinition('MySql-connection'));
|
||||
it(testName + ' Postgres', () => testDefinition('Postgres-connection'));
|
||||
if (localconfig.mysql) {
|
||||
it(testName + ' MySQL', () => testDefinition('MySql-connection'));
|
||||
}
|
||||
if (localconfig.postgres) {
|
||||
it(testName + ' Postgres', () => testDefinition('Postgres-connection'));
|
||||
}
|
||||
if (localconfig.mssql) {
|
||||
it(testName + ' Mssql', () => testDefinition('Mssql-connection'));
|
||||
}
|
||||
if (localconfig.oracle) {
|
||||
it(testName + ' Oracle', () => testDefinition('Oracle-connection'));
|
||||
}
|
||||
}
|
||||
|
||||
describe('Mutli-sql tests', () => {
|
||||
@@ -24,19 +36,31 @@ describe('Mutli-sql tests', () => {
|
||||
cy.testid('TabsPanel_buttonNewQuery').click();
|
||||
cy.wait(1000);
|
||||
cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');");
|
||||
|
||||
// rollback
|
||||
cy.testid('QueryTab_beginTransactionButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
cy.testid('QueryTab_executeButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
cy.testid('QueryTab_rollbackTransactionButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
|
||||
// should contain 4 rows
|
||||
cy.testid('SqlObjectList_container').contains('categories').click();
|
||||
cy.contains('Guitars').click();
|
||||
cy.testid('TableDataTab_refreshGrid').click();
|
||||
cy.contains('Rows: 4');
|
||||
|
||||
// commit
|
||||
cy.contains('Query #1').click();
|
||||
cy.testid('QueryTab_beginTransactionButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
cy.testid('QueryTab_executeButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
cy.testid('QueryTab_commitTransactionButton').click();
|
||||
cy.contains('Query execution finished');
|
||||
|
||||
// should contain 5 rows
|
||||
cy.testid('SqlObjectList_container').contains('categories').click();
|
||||
cy.contains('Guitars').click();
|
||||
cy.testid('TableDataTab_refreshGrid').click();
|
||||
|
||||
@@ -3,7 +3,6 @@ columns:
|
||||
- name: category_id
|
||||
type: int
|
||||
default: null
|
||||
autoIncrement: true
|
||||
notNull: true
|
||||
- name: category_name
|
||||
type: varchar(255)
|
||||
|
||||
@@ -49,3 +49,20 @@ services:
|
||||
image: redis
|
||||
ports:
|
||||
- 16011:6379
|
||||
|
||||
mssql:
|
||||
image: mcr.microsoft.com/mssql/server
|
||||
restart: always
|
||||
ports:
|
||||
- 16012:1433
|
||||
environment:
|
||||
- ACCEPT_EULA=Y
|
||||
- SA_PASSWORD=Pwd2020Db
|
||||
- MSSQL_PID=Express
|
||||
|
||||
oracle:
|
||||
image: gvenzl/oracle-xe:21-slim
|
||||
environment:
|
||||
ORACLE_PASSWORD: Pwd2020Db
|
||||
ports:
|
||||
- 16013:1521
|
||||
|
||||
17
e2e-tests/env/multi-sql/.env
vendored
17
e2e-tests/env/multi-sql/.env
vendored
@@ -1,4 +1,4 @@
|
||||
CONNECTIONS=mysql,postgres
|
||||
CONNECTIONS=mysql,postgres,mssql,oracle
|
||||
|
||||
LABEL_mysql=MySql-connection
|
||||
SERVER_mysql=localhost
|
||||
@@ -15,3 +15,18 @@ PASSWORD_postgres=Pwd2020Db
|
||||
PORT_postgres=16000
|
||||
ENGINE_postgres=postgres@dbgate-plugin-postgres
|
||||
DBCONFIG_postgres=[{"name":"PgChinook","connectionColor":"red"}]
|
||||
|
||||
LABEL_oracle=Oracle-connection
|
||||
SERVER_oracle=localhost
|
||||
USER_oracle=system
|
||||
PASSWORD_oracle=Pwd2020Db
|
||||
PORT_oracle=16013
|
||||
ENGINE_oracle=oracle@dbgate-plugin-oracle
|
||||
SERVICE_NAME_oracle=xe
|
||||
|
||||
LABEL_mssql=Mssql-connection
|
||||
SERVER_mssql=localhost
|
||||
USER_mssql=sa
|
||||
PASSWORD_mssql=Pwd2020Db
|
||||
PORT_mssql=16012
|
||||
ENGINE_mssql=mssql@dbgate-plugin-mssql
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const path = require('path');
|
||||
const localconfig = require('../.localconfig');
|
||||
|
||||
const dbgateApi = require('dbgate-api');
|
||||
dbgateApi.initializeApiEnvironment();
|
||||
@@ -7,11 +8,15 @@ dbgateApi.registerPlugins(dbgatePluginMysql);
|
||||
const dbgatePluginPostgres = require('dbgate-plugin-postgres');
|
||||
dbgateApi.registerPlugins(dbgatePluginPostgres);
|
||||
|
||||
async function createDb(connection, dropDbSql, createDbSql) {
|
||||
await dbgateApi.executeQuery({
|
||||
connection,
|
||||
sql: dropDbSql,
|
||||
});
|
||||
async function createDb(connection, dropDbSql, createDbSql, database = 'my_guitar_shop') {
|
||||
try {
|
||||
await dbgateApi.executeQuery({
|
||||
connection,
|
||||
sql: dropDbSql,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to drop database', err);
|
||||
}
|
||||
|
||||
await dbgateApi.executeQuery({
|
||||
connection,
|
||||
@@ -21,36 +26,69 @@ async function createDb(connection, dropDbSql, createDbSql) {
|
||||
await dbgateApi.importDbFromFolder({
|
||||
connection: {
|
||||
...connection,
|
||||
database: 'my_guitar_shop',
|
||||
database,
|
||||
},
|
||||
folder: path.resolve(path.join(__dirname, '../data/my-guitar-shop')),
|
||||
});
|
||||
}
|
||||
|
||||
async function run() {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_postgres,
|
||||
user: process.env.USER_postgres,
|
||||
password: process.env.PASSWORD_postgres,
|
||||
port: process.env.PORT_postgres,
|
||||
engine: 'postgres@dbgate-plugin-postgres',
|
||||
},
|
||||
'drop database if exists my_guitar_shop',
|
||||
'create database my_guitar_shop'
|
||||
);
|
||||
if (localconfig.postgres) {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_postgres,
|
||||
user: process.env.USER_postgres,
|
||||
password: process.env.PASSWORD_postgres,
|
||||
port: process.env.PORT_postgres,
|
||||
engine: 'postgres@dbgate-plugin-postgres',
|
||||
},
|
||||
'drop database if exists my_guitar_shop',
|
||||
'create database my_guitar_shop'
|
||||
);
|
||||
}
|
||||
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_mysql,
|
||||
user: process.env.USER_mysql,
|
||||
password: process.env.PASSWORD_mysql,
|
||||
port: process.env.PORT_mysql,
|
||||
engine: 'mysql@dbgate-plugin-mysql',
|
||||
},
|
||||
'drop database if exists my_guitar_shop',
|
||||
'create database my_guitar_shop'
|
||||
);
|
||||
if (localconfig.mysql) {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_mysql,
|
||||
user: process.env.USER_mysql,
|
||||
password: process.env.PASSWORD_mysql,
|
||||
port: process.env.PORT_mysql,
|
||||
engine: 'mysql@dbgate-plugin-mysql',
|
||||
},
|
||||
'drop database if exists my_guitar_shop',
|
||||
'create database my_guitar_shop'
|
||||
);
|
||||
}
|
||||
|
||||
if (localconfig.mssql) {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_mssql,
|
||||
user: process.env.USER_mssql,
|
||||
password: process.env.PASSWORD_mssql,
|
||||
port: process.env.PORT_mssql,
|
||||
engine: 'mssql@dbgate-plugin-mssql',
|
||||
},
|
||||
'drop database if exists my_guitar_shop',
|
||||
'create database my_guitar_shop'
|
||||
);
|
||||
}
|
||||
|
||||
if (localconfig.oracle) {
|
||||
await createDb(
|
||||
{
|
||||
server: process.env.SERVER_oracle,
|
||||
user: process.env.USER_oracle,
|
||||
password: process.env.PASSWORD_oracle,
|
||||
port: process.env.PORT_oracle,
|
||||
engine: 'oracle@dbgate-plugin-oracle',
|
||||
},
|
||||
'DROP USER C##my_guitar_shop',
|
||||
'CREATE USER c##my_guitar_shop IDENTIFIED BY my_guitar_shop DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA 10M ON users',
|
||||
'C##my_guitar_shop'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
dbgateApi.runScript(run);
|
||||
|
||||
Reference in New Issue
Block a user