DB
This commit is contained in:
28
tests/base/case1-payload.js
Normal file
28
tests/base/case1-payload.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
async function insert() {
|
||||
const res = await asyncCall(
|
||||
db,
|
||||
squel.insert().into("testTable").set("col", "test me now").toString()
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function createSQL(id) {
|
||||
return squel.select().from("testTable").where("id = ?", id).toString();
|
||||
}
|
||||
|
||||
async function main(input) {
|
||||
const inserted = await insert();
|
||||
|
||||
log(inserted);
|
||||
|
||||
const sql = createSQL(inserted.rows.insertId);
|
||||
const res = await asyncCall(db, sql);
|
||||
|
||||
log(res.rows);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -1,14 +1,17 @@
|
||||
import createProject from "../functions/createProject";
|
||||
import createQuery from "../functions/createQuery";
|
||||
import runQuery from "../functions/runQuery";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const project = await createProject("Test Project");
|
||||
|
||||
const payloadPath = path.join(__dirname, "case1-payload.js");
|
||||
const query = await createQuery(
|
||||
project,
|
||||
"async function main(input) { return `Hello, ${input.name}!`; }"
|
||||
fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
||||
);
|
||||
|
||||
console.log(query);
|
||||
|
||||
3
tests/config.ts
Normal file
3
tests/config.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const config = {
|
||||
url: "http://localhost:3054",
|
||||
};
|
||||
@ -1,14 +1,12 @@
|
||||
import axios from "axios";
|
||||
import { config } from "tests/config";
|
||||
|
||||
export default async (query: { id: string }, module: { id: string }) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
"http://localhost:3000/query/module/add",
|
||||
{
|
||||
queryId: query.id,
|
||||
moduleId: module.id,
|
||||
}
|
||||
);
|
||||
const response = await axios.post(`${config.url}/query/module/add`, {
|
||||
queryId: query.id,
|
||||
moduleId: module.id,
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import axios from "axios";
|
||||
import { config } from "tests/config";
|
||||
|
||||
export default async (query: { id: string }, plugin: { id: string }) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
"http://localhost:3000/query/plugin/add",
|
||||
{
|
||||
queryId: query.id,
|
||||
pluginId: plugin.id,
|
||||
}
|
||||
);
|
||||
const response = await axios.post(`${config.url}/query/plugin/add`, {
|
||||
queryId: query.id,
|
||||
pluginId: plugin.id,
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import axios from "axios";
|
||||
import { config } from "tests/config";
|
||||
|
||||
export default async (name: string, sourcePath: string) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
"http://localhost:3000/query/module/create",
|
||||
{
|
||||
name,
|
||||
sourcePath,
|
||||
}
|
||||
);
|
||||
const response = await axios.post(`${config.url}/query/module/create`, {
|
||||
name,
|
||||
sourcePath,
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
import axios from "axios";
|
||||
import { config as appConfig } from "../config";
|
||||
|
||||
export default async (name: string, className: string, config: string) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
"http://localhost:3000/query/plugin/create",
|
||||
{
|
||||
name,
|
||||
class: className,
|
||||
config,
|
||||
}
|
||||
);
|
||||
const response = await axios.post(`${appConfig.url}/query/plugin/create`, {
|
||||
name,
|
||||
class: className,
|
||||
config,
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import axios from "axios";
|
||||
import { config } from "../config";
|
||||
|
||||
const createProject = async (name: string) => {
|
||||
try {
|
||||
const response = await axios.put("http://localhost:3000/project/create", {
|
||||
const response = await axios.put(`${config.url}/project/create`, {
|
||||
name: name,
|
||||
});
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import axios from "axios";
|
||||
import { config } from "../config";
|
||||
|
||||
export default async (project: { token: string }, source: string) => {
|
||||
try {
|
||||
const response = await axios.post("http://localhost:3000/query/create", {
|
||||
const response = await axios.post(`${config.url}/query/create`, {
|
||||
source,
|
||||
projectToken: project.token,
|
||||
});
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import axios from "axios";
|
||||
import { config } from "../config";
|
||||
|
||||
export default async (token: string, queryData: Record<string, any>) => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`http://localhost:3000/query/run/${token}`,
|
||||
`${config.url}/query/run/${token}`,
|
||||
queryData
|
||||
);
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import axios from "axios";
|
||||
import { config } from "../config";
|
||||
|
||||
export default async (query: { id: string; source: string }) => {
|
||||
try {
|
||||
const response = await axios.post("http://localhost:3000/query/update", {
|
||||
const response = await axios.post(`${config.url}/query/update`, {
|
||||
queryId: query.id,
|
||||
source: query.source,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user