qualiteer/lib/database/queries/catalog.js

101 lines
2.6 KiB
JavaScript
Raw Normal View History

2022-05-08 01:36:22 +00:00
import pg from "../postgres.js";
// Imports
import {
insertQuery,
selectWhereAnyQuery,
updateWhereAnyQuery,
} from "../pg-query.js";
// Constants
const table = "tests";
2022-08-06 21:21:41 +00:00
const PG_DISABLED = process.env.POSTGRES_DISABLED;
2022-05-08 01:36:22 +00:00
// Queries
2022-08-06 21:21:41 +00:00
const testsMock = () => {
return [
{
id: 0,
name: "single",
class: "single.js",
image: "node:latest",
isCompound: false,
type: "api",
description: "This is a single test",
tags: ["cron_1hour","reg_us", "env_ci", "proj_core", "skip_alt"],
path: "tests/assets/suite/single.js",
created: Date.now(),
mergeRequest: "https://example.com"
},
{
id: 1,
name: "failing",
class: "failing.js",
image: "node:latest",
isCompound: false,
type: "ui",
description: "This is a failing test",
tags: ["cron_1hour","reg_us", "env_ci", "proj_core"],
path: "tests/assets/suite/failing.js",
created: Date.now(),
mergeRequest: "https://example.com"
},
{
id: 2,
name: "primary",
class: "primary.js",
image: "node:latest",
isCompound: true,
type: "api",
description: "This is a primary test",
tags: ["cron_1hour","reg_us", "proj_core", "skip_alt", "compound_secondary"],
path: "tests/assets/suite/primary.js",
created: Date.now(),
mergeRequest: "https://example.com"
}, {
id: 3,
name: "secondary",
class: "secondary.js",
image: "node:latest",
isCompound: true,
type: "api",
description: "This is a secondary test",
tags: ["cron_1hour","reg_us", "proj_core", "compound_tertiary"],
path: "tests/assets/suite/secondary.js",
created: Date.now(),
mergeRequest: "https://example.com"
},
{
id: 4,
name: "tertiary",
class: "tertiary.js",
image: "node:latest",
isCompound: true,
type: "api",
description: "This is a single test",
tags: ["cron_1hour","reg_us", "proj_core"],
path: "tests/assets/suite/tertiary.js",
created: Date.now(),
mergeRequest: "https://example.com"
},
];
};
const mappingsMock = () => {
return [
["primary", "secondary1", "tertiary1"],
["primary", "secondary1", "tertiary2"],
["primary", "secondary2", "tertiary3"],
];
}
export const getTests = async () => {
if (PG_DISABLED) return testsMock();
const query = `SELECT * from ${table}`;
return pg.query(query);
};
export const getPipelineMappings = async () => {
if (PG_DISABLED) return mappingsMock();
2022-05-08 01:36:22 +00:00
const query = `SELECT * from ${table}`;
return pg.query(query);
};