text: const httpStatus = require("http-status");
  const pick = require("../utils/pick");
  const ApiError = require("../utils/ApiError");
  const catchAsync = require("../utils/catchAsync");
  const { testService } = require("../services");
  
  const createTest = catchAsync(async (req, res) => {
    const test = await testService.createTest(req.body);
    res.status(httpStatus.CREATED).send(test);
  });
  
  const getTests = catchAsync(async (req, res) => {
    const filter = pick(req.query, ["name", "role"]);
    const options = pick(req.query, ["sortBy", "limit", "page"]);
    const result = await testService.queryTests(filter, options);
    res.send(result);
  });
  
  const getTest = catchAsync(async (req, res) => {
    const test = await testService.getTestById(req.params.TestId);
    if (!test) {
      throw new ApiError(httpStatus.NOT_FOUND, "Test not found");
    }
    res.send(test);
  });
  
  const updateTest = catchAsync(async (req, res) => {
    const test = await testService.updateTestById(
      req.params.TestId,
      req.body
    );
    res.send(test);
  });
  
  const deleteTest = catchAsync(async (req, res) => {
    await testService.deleteTestById(req.params.TestId);
    res.status(httpStatus.NO_CONTENT).send();
  });
  
  module.exports = {
    createTest,
    getTests,
    getTest,
    updateTest,
    deleteTest,
  };
  