Skip to content

Commit

Permalink
add automation service field to TestPlanRun model
Browse files Browse the repository at this point in the history
  • Loading branch information
outofambit committed Nov 14, 2024
1 parent 98776c1 commit 79e0c69
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion server/controllers/AutomationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const {
findOrCreateBrowserVersion
} = require('../models/services/BrowserService');
const { HttpQueryError } = require('apollo-server-core');
const { COLLECTION_JOB_STATUS, isJobStatusFinal } = require('../util/enums');
const {
COLLECTION_JOB_STATUS,
isJobStatusFinal,
AUTOMATION_SERVICE

Check failure on line 24 in server/controllers/AutomationController.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

'AUTOMATION_SERVICE' is assigned a value but never used

Check failure on line 24 in server/controllers/AutomationController.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

'AUTOMATION_SERVICE' is assigned a value but never used
} = require('../util/enums');
const populateData = require('../services/PopulatedData/populateData');
const {
getFinalizedTestResults
Expand Down
10 changes: 10 additions & 0 deletions server/models/TestPlanRun.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { AUTOMATION_SERVICE } = require('../util/enums');

const MODEL_NAME = 'TestPlanRun';

module.exports = function (sequelize, DataTypes) {
Expand All @@ -18,6 +20,11 @@ module.exports = function (sequelize, DataTypes) {
allowNull: false,
defaultValue: false
},
automationService: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null
},
isPrimary: {
type: DataTypes.BOOLEAN,
allowNull: true,
Expand All @@ -30,6 +37,9 @@ module.exports = function (sequelize, DataTypes) {
}
);

Model.GITHUB_ACTIONS = AUTOMATION_SERVICE.GITHUB_ACTIONS;
Model.AZURE_PIPELINES = AUTOMATION_SERVICE.AZURE_PIPELINES;

Model.TEST_RESULT_ASSOCIATION = { as: 'testResults' };

Model.TEST_PLAN_REPORT_ASSOCIATION = { foreignKey: 'testPlanReportId' };
Expand Down
7 changes: 5 additions & 2 deletions server/models/services/TestPlanRunService.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const getTestPlanRuns = async ({
/**
* @param {object} options
* @param {object} options.values - values to be used to create the TestPlanRun
* @param {string} options.values.automationService
* @param {string[]} options.testPlanRunAttributes - TestPlanRun attributes to be returned in the result
* @param {string[]} options.nestedTestPlanRunAttributes - TestPlanRun attributes associated to the TestPlanReport model to be returned
* @param {string[]} options.testPlanReportAttributes - TestPlanReport attributes to be returned in the result
Expand All @@ -233,7 +234,8 @@ const createTestPlanRun = async ({
testerUserId,
testPlanReportId,
testResults = [],
isAutomated = false
isAutomated = false,
automationService = null
},
testPlanRunAttributes = TEST_PLAN_RUN_ATTRIBUTES,
nestedTestPlanRunAttributes = TEST_PLAN_RUN_ATTRIBUTES,
Expand Down Expand Up @@ -270,7 +272,8 @@ const createTestPlanRun = async ({
testerUserId,
testPlanReportId,
testResults,
initiatedByAutomation: isAutomated
initiatedByAutomation: isAutomated,
automationService
},
transaction
});
Expand Down
13 changes: 12 additions & 1 deletion server/util/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ const isJobStatusFinal = status =>
status === COLLECTION_JOB_STATUS.CANCELLED ||
status === COLLECTION_JOB_STATUS.ERROR;

/**
* Enum for possible workflow services
* @readonly
* @enum {string}
*/
const AUTOMATION_SERVICE = Object.freeze({
GITHUB_ACTIONS: 'GITHUB_ACTIONS',
AZURE_PIPELINES: 'AZURE_PIPELINES'
});

module.exports = {
COLLECTION_JOB_STATUS,
isJobStatusFinal
isJobStatusFinal,
AUTOMATION_SERVICE
};

0 comments on commit 79e0c69

Please sign in to comment.