100 lines
2.6 KiB
JavaScript
100 lines
2.6 KiB
JavaScript
import pg from "../postgres.js";
|
|
// Imports
|
|
import {
|
|
insertQuery,
|
|
selectWhereAnyQuery,
|
|
updateWhereAnyQuery,
|
|
} from "../pg-query.js";
|
|
// Constants
|
|
const table = "tests";
|
|
const PG_DISABLED = process.env.POSTGRES_DISABLED;
|
|
// Queries
|
|
|
|
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();
|
|
const query = `SELECT * from ${table}`;
|
|
return pg.query(query);
|
|
};
|