Introduce prettier
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const { DataTypes } = require("sequelize");
|
||||
const defineRun = require('../../models/runs');
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
router.delete("/:runId", async (req, res) => {
|
||||
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");
|
||||
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");
|
||||
res.status(500).send('Internal Server Error');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const { DataTypes } = require("sequelize");
|
||||
const defineRun = require('../../models/runs');
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
router.put("/:runId", async (req, res) => {
|
||||
router.put('/:runId', async (req, res) => {
|
||||
const runId = req.params.runId;
|
||||
const updateRun = req.body;
|
||||
try {
|
||||
const testrun = await Run.findByPk(runId);
|
||||
if (!testrun) {
|
||||
return res.status(404).send("Run not found");
|
||||
return res.status(404).send('Run not found');
|
||||
}
|
||||
|
||||
delete updateRun.Steps;
|
||||
@@ -20,7 +20,7 @@ module.exports = function (sequelize) {
|
||||
res.json(testrun);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal Server Error");
|
||||
res.status(500).send('Internal Server Error');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const defineRun = require('../../models/runs');
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
module.exports = function(sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes)
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
router.get("/", async (req, res) => {
|
||||
router.get('/', async (req, res) => {
|
||||
const { projectId } = req.query;
|
||||
|
||||
if (!projectId) {
|
||||
@@ -16,15 +16,15 @@ module.exports = function(sequelize) {
|
||||
try {
|
||||
const runs = await Run.findAll({
|
||||
where: {
|
||||
projectId: projectId
|
||||
}
|
||||
projectId: projectId,
|
||||
},
|
||||
});
|
||||
res.json(runs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal Server Error");
|
||||
res.status(500).send('Internal Server Error');
|
||||
}
|
||||
});
|
||||
|
||||
return router;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const { DataTypes } = require("sequelize");
|
||||
const defineRun = require('../../models/runs');
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
|
||||
router.post("/", async (req, res) => {
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
const { name, configurations, description, state, projectId } = req.body;
|
||||
if (!name || !projectId) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Name and projectId are required" });
|
||||
return res.status(400).json({ error: 'Name and projectId are required' });
|
||||
}
|
||||
|
||||
const newRun = await Run.create({
|
||||
@@ -25,7 +23,7 @@ module.exports = function (sequelize) {
|
||||
|
||||
res.json(newRun);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: "Internal server error" });
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
const express = require("express");
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const defineRun = require("../../models/runs");
|
||||
const defineRunCase = require("../../models/runCases");
|
||||
const { DataTypes, literal } = require("sequelize");
|
||||
const defineRun = require('../../models/runs');
|
||||
const defineRunCase = require('../../models/runCases');
|
||||
const { DataTypes, literal } = require('sequelize');
|
||||
|
||||
module.exports = function (sequelize) {
|
||||
const Run = defineRun(sequelize, DataTypes);
|
||||
const RunCase = defineRunCase(sequelize, DataTypes);
|
||||
|
||||
router.get("/:runId", async (req, res) => {
|
||||
router.get('/:runId', async (req, res) => {
|
||||
const runId = req.params.runId;
|
||||
|
||||
if (!runId) {
|
||||
return res.status(400).json({ error: "runId is required" });
|
||||
return res.status(400).json({ error: 'runId is required' });
|
||||
}
|
||||
|
||||
try {
|
||||
const run = await Run.findByPk(runId);
|
||||
if (!run) {
|
||||
return res.status(404).send("Run not found");
|
||||
return res.status(404).send('Run not found');
|
||||
}
|
||||
|
||||
// Counts test case status belonging to the run
|
||||
const statusCounts = await RunCase.findAll({
|
||||
attributes: ["status", [literal("COUNT(*)"), "count"]],
|
||||
attributes: ['status', [literal('COUNT(*)'), 'count']],
|
||||
where: {
|
||||
runId: run.id,
|
||||
},
|
||||
group: ["status"],
|
||||
group: ['status'],
|
||||
});
|
||||
|
||||
res.json({ run, statusCounts });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).send("Internal Server Error");
|
||||
res.status(500).send('Internal Server Error');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user