Implemented test run deletion

This commit is contained in:
Takeshi Kimata
2024-04-13 13:33:05 +09:00
parent c852d2e0cd
commit 42ab034a59
7 changed files with 46 additions and 18 deletions

View File

@@ -79,11 +79,13 @@ app.use("/attachments", attachmentsDownloadRoute);
// "/runs"
const runsIndexRoute = require("./routes/runs/index")(sequelize);
const runsShowRoute = require("./routes/cases/show")(sequelize);
const runsShowRoute = require("./routes/runs/show")(sequelize);
const runsNewRoute = require("./routes/runs/new")(sequelize);
const runDeleteRoute = require("./routes/runs/delete")(sequelize);
app.use("/runs", runsIndexRoute);
app.use("/runs", runsShowRoute);
app.use("/runs", runsNewRoute);
app.use("/runs", runDeleteRoute);
const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {

View File

@@ -0,0 +1,25 @@
const express = require("express");
const router = express.Router();
const defineRun = require("../../models/runs");
const { DataTypes } = require("sequelize");
module.exports = function (sequelize) {
const Run = defineRun(sequelize, DataTypes);
router.delete("/:runId", async (req, res) => {
const runId = req.params.runId;
try {
const testrun = await Run.findByPk(runId);
if (!testrun) {
return res.status(404).send("Run not found");
}
await testrun.destroy();
res.status(204).send();
} catch (error) {
console.error(error);
res.status(500).send("Internal Server Error");
}
});
return router;
};

View File

@@ -54,8 +54,8 @@ module.exports = {
{
name: "Run 1",
projectId: 1,
configurations: null,
description: null,
configurations: 1,
description: "",
state: 1,
createdAt: new Date(),
updatedAt: new Date(),
@@ -63,8 +63,8 @@ module.exports = {
{
name: "Run 2",
projectId: 1,
configurations: null,
description: null,
configurations: 1,
description: "",
state: 1,
createdAt: new Date(),
updatedAt: new Date(),
@@ -72,8 +72,8 @@ module.exports = {
{
name: "Run 3",
projectId: 1,
configurations: null,
description: null,
configurations: 1,
description: "",
state: 1,
createdAt: new Date(),
updatedAt: new Date(),