import pg from "../postgres.js";
// Imports
import {
  insertQuery,
  selectWhereAnyQuery,
  updateWhereAnyQuery,
} from "../pg-query.js";
// Constants
const table = "silenced_tests";
const PG_DISABLED = process.env.POSTGRES_DISABLED;

const silencedMock = () => {
  return [
    {
      name: `failing`,
      class: `failing.js`,
      method: "FAKEMETHOD",
      id: 0,
      silencedUntil: new Date().toJSON(),
    },
  ];
};

// Queries
export const getSilencedTests = async () => {
  if (PG_DISABLED) return silencedMock();
  const query = `SELECT * from ${table}`;
  return pg.query(query);
};
