Browse Source

refactor/Improved folder structure

pull/3358/head
Muhammed Mustafa 2 years ago
parent
commit
b8530a2694
  1. 5
      packages/nocodb/package.json
  2. 35
      packages/nocodb/tests/unit/index.test.ts
  3. 0
      packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts
  4. 34
      packages/nocodb/tests/unit/rest/index.test.ts

5
packages/nocodb/package.json

@ -21,11 +21,10 @@
"local:test:graphql": "cross-env DATABASE_URL=mysql://root:password@localhost:3306/sakila TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit", "local:test:graphql": "cross-env DATABASE_URL=mysql://root:password@localhost:3306/sakila TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit",
"test:graphql": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit", "test:graphql": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/graphql.test.ts --recursive --timeout 10000 --exit",
"test:grpc": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/grpc.test.ts --recursive --timeout 10000 --exit", "test:grpc": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register src/__tests__/grpc.test.ts --recursive --timeout 10000 --exit",
"local:test:rest": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/rest/index.test.ts --recursive --timeout 300000 --exit --delay", "local:test:unit": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"test:rest": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/rest/index.test.ts --recursive --timeout 300000 --exit --delay", "test:unit": "cross-env TS_NODE_PROJECT=./tests/unit/tsconfig.json mocha -r ts-node/register tests/unit/index.test.ts --recursive --timeout 300000 --exit --delay",
"test1": "run-s build test:*", "test1": "run-s build test:*",
"test:lint": "tslint --project . && prettier \"src/**/*.ts\" --list-different", "test:lint": "tslint --project . && prettier \"src/**/*.ts\" --list-different",
"test:unit": "nyc --silent ava",
"watch": "run-s clean build:main && run-p \"build:main -- -w\" \"test:unit -- --watch\"", "watch": "run-s clean build:main && run-p \"build:main -- -w\" \"test:unit -- --watch\"",
"cov": "run-s build test:unit cov:html && open-cli coverage/index.html", "cov": "run-s build test:unit cov:html && open-cli coverage/index.html",
"cov:html": "nyc report --reporter=html", "cov:html": "nyc report --reporter=html",

35
packages/nocodb/tests/unit/index.test.ts

@ -0,0 +1,35 @@
import 'mocha';
import knex from 'knex';
import { dbName } from './dbConfig';
import restTests from './rest/index.test';
process.env.NODE_ENV = 'test';
process.env.TEST = 'test';
process.env.NC_DISABLE_CACHE = 'true';
const setupTestMetaDb = async () => {
const knexClient = knex({
client: 'mysql2',
connection: {
host: 'localhost',
port: 3306,
user: 'root',
password: 'password',
},
});
try {
await knexClient.raw(`DROP DATABASE ${dbName}`);
} catch (e) {}
await knexClient.raw(`CREATE DATABASE ${dbName}`);
}
(async function() {
await setupTestMetaDb();
restTests();
run();
})();

0
packages/nocodb/tests/unit/model/baseModelSql.test.ts → packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts

34
packages/nocodb/tests/unit/rest/index.test.ts

@ -4,39 +4,15 @@ import projectTests from './tests/project.test';
import tableTests from './tests/table.test'; import tableTests from './tests/table.test';
import tableRowTests from './tests/tableRow.test'; import tableRowTests from './tests/tableRow.test';
import viewRowTests from './tests/viewRow.test'; import viewRowTests from './tests/viewRow.test';
import knex from 'knex';
import { dbName } from '../dbConfig';
process.env.NODE_ENV = 'test';
process.env.TEST = 'test';
process.env.NC_DISABLE_CACHE = 'true';
const setupTestMetaDb = async () => {
const knexClient = knex({
client: 'mysql2',
connection: {
host: 'localhost',
port: 3306,
user: 'root',
password: 'password',
},
});
try {
await knexClient.raw(`DROP DATABASE ${dbName}`);
} catch (e) {}
await knexClient.raw(`CREATE DATABASE ${dbName}`);
}
(async function() {
await setupTestMetaDb();
function restTests() {
authTests(); authTests();
projectTests(); projectTests();
tableTests(); tableTests();
tableRowTests(); tableRowTests();
viewRowTests(); viewRowTests();
}
run(); export default function () {
})(); describe('Rest', restTests);
}
Loading…
Cancel
Save