const assert = require("node:assert/strict");
const db = require("../src/db/models");

db.sequelize.options.logging = false;

async function run() {
  const users = await db.users.findAll({ attributes: ["email"], raw: true });
  assert.equal(users.length, 3, "The template must contain exactly three fictional demo users");
  assert.ok(
    users.every((user) => user.email.endsWith("@coaching-demo.invalid")),
    "Every template user must use the reserved synthetic demo domain",
  );
  assert.equal(await db.file.count(), 0, "The template database must not contain uploads");
  console.log("live_data_inventory_check=passed");
}

run()
  .then(() => db.sequelize.close())
  .catch(async (error) => {
    console.error(error);
    await db.sequelize.close();
    process.exitCode = 1;
  });
