From 387c1ecd6927d51628d4ac5c186aa13c5a7f4b9e Mon Sep 17 00:00:00 2001 From: JeraldJF Date: Tue, 11 Jun 2024 12:27:42 +0530 Subject: [PATCH 1/2] Sanketika-Obsrv/issue-tracker#234: transaction management removed --- .../DatasetCreate/DatasetCreate.ts | 11 +-- .../DatasetStatusTransition.ts | 38 ++++------ .../DatasetUpdate/DatasetUpdate.ts | 18 ++--- .../DatasetCreate/DatasetCreate.spec.ts | 30 +------- .../DatasetDelete.spec.ts | 10 --- .../DatasetLive.spec.ts | 19 ----- .../DatasetReadyToPublish.spec.ts | 19 ----- .../DatasetRetire.spec.ts | 43 ----------- .../DatasetStatusTransition.spec.ts | 11 +-- .../DatasetUpdate/DatasetDedup.spec.ts | 16 ---- .../DatasetUpdate/DatasetDenorm.spec.ts | 34 --------- .../DatasetUpdate/DatasetExtraction.spec.ts | 16 ---- .../DatasetUpdate/DatasetTags.spec.ts | 31 -------- .../DatasetTransformation.spec.ts | 43 ----------- .../DatasetUpdate/DatasetUpdate.spec.ts | 75 ++----------------- .../DatasetUpdate/DatasetValidation.spec.ts | 16 ---- 16 files changed, 34 insertions(+), 396 deletions(-) diff --git a/api-service/src/v2/controllers/DatasetCreate/DatasetCreate.ts b/api-service/src/v2/controllers/DatasetCreate/DatasetCreate.ts index 7a21ce1f..07542074 100644 --- a/api-service/src/v2/controllers/DatasetCreate/DatasetCreate.ts +++ b/api-service/src/v2/controllers/DatasetCreate/DatasetCreate.ts @@ -9,7 +9,7 @@ import { ResponseHandler } from "../../helpers/ResponseHandler"; import httpStatus from "http-status"; import { defaultDatasetConfig, defaultMasterConfig } from "../../configs/DatasetConfigDefault"; import { DatasetType } from "../../types/DatasetModels"; -import { query, sequelize } from "../../connections/databaseConnection"; +import { query } from "../../connections/databaseConnection"; import { ErrorObject } from "../../types/ResponseModel"; import { DatasourceDraft } from "../../models/DatasourceDraft"; import { DatasetTransformationsDraft } from "../../models/TransformationDraft"; @@ -20,7 +20,6 @@ const datasetCreate = async (req: Request, res: Response) => { const requestBody = req.body const msgid = _.get(req, ["body", "params", "msgid"]); const resmsgid = _.get(res, "resmsgid"); - const transact = await sequelize.transaction() try { const datasetId = _.get(req, ["body", "request", "dataset_id"]) setReqDatasetId(req, datasetId) @@ -66,25 +65,23 @@ const datasetCreate = async (req: Request, res: Response) => { const datasetPayload: any = await getDefaultValue(datasetBody); const data = { ...datasetPayload, version_key: Date.now().toString() } - const response = await DatasetDraft.create(data, { transaction: transact }) + const response = await DatasetDraft.create(data) const { dataset_config, denorm_config, transformation_config, data_schema, id, dataset_id } = data const datasourcePayload = await generateDataSource({ indexCol: _.get(dataset_config, ["timestamp_key"]), data_schema, id, dataset_id, denorm_config, transformation_config, action:"create" }) - await DatasourceDraft.create(datasourcePayload, { transaction: transact }) + await DatasourceDraft.create(datasourcePayload) logger.info({ apiId, message: `Datasource created successsfully for the dataset:${id}` }) const transformationConfig: any = getTransformationConfig({ transformationPayload: _.get(datasetBody, "transformations_config"), datasetId: _.get(datasetPayload, "id") }) if (!_.isEmpty(transformationConfig)) { - await DatasetTransformationsDraft.bulkCreate(transformationConfig), { transaction: transact }; + await DatasetTransformationsDraft.bulkCreate(transformationConfig); logger.info({ apiId, message: `Dataset transformations records created successsfully for dataset:${id}` }) } - await transact.commit() const responseData = { id: _.get(response, ["dataValues", "id"]) || "", version_key: data.version_key } logger.info({ apiId, msgid, requestBody, resmsgid, message: `Dataset Created Successfully with id:${_.get(response, ["dataValues", "id"])}`, response: responseData }) ResponseHandler.successResponse(req, res, { status: httpStatus.OK, data: responseData }); } catch (error: any) { - await transact.rollback() const code = _.get(error, "code") || "DATASET_CREATION_FAILURE" logger.error({ ...error, apiId, code, msgid, requestBody, resmsgid }) let errorMessage = error; diff --git a/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts b/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts index 946d2139..eafbe789 100644 --- a/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts +++ b/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts @@ -8,7 +8,6 @@ import { schemaValidation } from "../../services/ValidationService"; import StatusTransitionSchema from "./RequestValidationSchema.json"; import ReadyToPublishSchema from "./ReadyToPublishSchema.json" import httpStatus from "http-status"; -import { sequelize } from "../../connections/databaseConnection"; import { DatasetTransformationsDraft } from "../../models/TransformationDraft"; import { DatasourceDraft } from "../../models/DatasourceDraft"; import { DatasetSourceConfigDraft } from "../../models/DatasetSourceConfigDraft"; @@ -42,8 +41,6 @@ const datasetStatusTransition = async (req: Request, res: Response) => { const requestBody = req.body const msgid = _.get(req, ["body", "params", "msgid"]); const resmsgid = _.get(res, "resmsgid"); - try { - const transact = await sequelize.transaction() try { const { dataset_id, status } = _.get(requestBody, "request"); setReqDatasetId(req, dataset_id) @@ -88,13 +85,11 @@ const datasetStatusTransition = async (req: Request, res: Response) => { } const transitionCommands = _.get(statusTransitionCommands, status) - await executeTransition({ transitionCommands, dataset: datasetRecord, transact }) + await executeTransition({ transitionCommands, dataset: datasetRecord }) - await transact.commit(); logger.info({ apiId, msgid, requestBody, resmsgid, message: `Dataset status transition to ${status} successful with id:${dataset_id}` }) ResponseHandler.successResponse(req, res, { status: httpStatus.OK, data: { message: `Dataset status transition to ${status} successful`, dataset_id } }); } catch (error: any) { - await transact.rollback(); const code = _.get(error, "code") || errorCode logger.error(error, apiId, msgid, code, requestBody, resmsgid) let errorMessage = error; @@ -104,11 +99,6 @@ const datasetStatusTransition = async (req: Request, res: Response) => { } ResponseHandler.errorResponse(errorMessage, req, res); } - } catch (error: any) { - const errMessage = error.message - logger.error({ message: errMessage, msgid, resmsgid, apiId }) - ResponseHandler.errorResponse(errMessage, req, res); - } } const fetchDataset = async (configs: Record) => { @@ -125,10 +115,10 @@ const fetchDataset = async (configs: Record) => { } const executeTransition = async (configs: Record) => { - const { transitionCommands, dataset, transact } = configs + const { transitionCommands, dataset } = configs const transitionPromises = _.map(transitionCommands, async command => { const commandWorkflow = _.get(commandExecutors, command) - return commandWorkflow({ dataset, transact }) + return commandWorkflow({ dataset }) }) await Promise.all(transitionPromises) } @@ -150,17 +140,17 @@ const validateDataset = async (configs: Record) => { //DELETE_DRAFT_DATASETS const deleteDataset = async (configs: Record) => { - const { dataset, transact } = configs + const { dataset } = configs const { id } = dataset - await deleteDraftRecords({ dataset_id: id, transact }) + await deleteDraftRecords({ dataset_id: id }) } const deleteDraftRecords = async (config: Record) => { const { dataset_id, transact } = config; - await DatasetTransformationsDraft.destroy({ where: { dataset_id }, transaction: transact }) - await DatasetSourceConfigDraft.destroy({ where: { dataset_id }, transaction: transact }) - await DatasourceDraft.destroy({ where: { dataset_id }, transaction: transact }) - await DatasetDraft.destroy({ where: { id: dataset_id }, transaction: transact }) + await DatasetTransformationsDraft.destroy({ where: { dataset_id } }) + await DatasetSourceConfigDraft.destroy({ where: { dataset_id } }) + await DatasourceDraft.destroy({ where: { dataset_id } }) + await DatasetDraft.destroy({ where: { id: dataset_id } }) } //PUBLISH_DATASET @@ -195,12 +185,12 @@ const checkDatasetDenorm = async (payload: Record) => { //SET_DATASET_TO_RETIRE const setDatasetRetired = async (config: Record) => { - const { dataset, transact } = config; + const { dataset } = config; const { dataset_id } = dataset - await Dataset.update({ status: DatasetStatus.Retired }, { where: { dataset_id }, transaction: transact }) - await DatasetSourceConfig.update({ status: DatasetStatus.Retired }, { where: { dataset_id }, transaction: transact }) - await Datasource.update({ status: DatasetStatus.Retired }, { where: { dataset_id }, transaction: transact }) - await DatasetTransformations.update({ status: DatasetStatus.Retired }, { where: { dataset_id }, transaction: transact }) + await Dataset.update({ status: DatasetStatus.Retired }, { where: { dataset_id } }) + await DatasetSourceConfig.update({ status: DatasetStatus.Retired }, { where: { dataset_id } }) + await Datasource.update({ status: DatasetStatus.Retired }, { where: { dataset_id } }) + await DatasetTransformations.update({ status: DatasetStatus.Retired }, { where: { dataset_id } }) } //DELETE_SUPERVISORS diff --git a/api-service/src/v2/controllers/DatasetUpdate/DatasetUpdate.ts b/api-service/src/v2/controllers/DatasetUpdate/DatasetUpdate.ts index eb6c386b..2de32ead 100644 --- a/api-service/src/v2/controllers/DatasetUpdate/DatasetUpdate.ts +++ b/api-service/src/v2/controllers/DatasetUpdate/DatasetUpdate.ts @@ -11,7 +11,6 @@ import logger from "../../logger"; import { defaultDatasetConfig } from "../../configs/DatasetConfigDefault"; import { DatasetTransformationsDraft } from "../../models/TransformationDraft"; import { generateDataSource, getDraftTransformations, getDuplicateConfigs, setReqDatasetId } from "../../services/DatasetService"; -import { sequelize } from "../../connections/databaseConnection"; import { DatasourceDraft } from "../../models/DatasourceDraft"; import { ingestionConfig } from "../../configs/IngestionConfig"; import { getDefaultValue } from "../DatasetCreate/DatasetCreate"; @@ -24,7 +23,6 @@ const datasetUpdate = async (req: Request, res: Response) => { const requestBody = req.body const msgid = _.get(req, ["body", "params", "msgid"]); const resmsgid = _.get(res, "resmsgid"); - const transact = await sequelize.transaction(); try { const datasetId = _.get(req, ["body", "request", "dataset_id"]) setReqDatasetId(req, datasetId) @@ -104,24 +102,22 @@ const datasetUpdate = async (req: Request, res: Response) => { const updatedPayload = await getDefaultValue(datasetPayload) logger.debug({ datasetPayload }) const transformationConfigs = _.get(datasetBody, "transformation_config") - await manageTransformations(transformationConfigs, dataset_id, transact); + await manageTransformations(transformationConfigs, dataset_id); const { data_schema } = datasetBody if (data_schema) { const { transformation_config } = datasetBody const { dataset_config, id, dataset_id, denorm_config } = updatedPayload const datasourcePayload = await generateDataSource({ indexCol: _.get(dataset_config, ["timestamp_key"]), transformation_config, denorm_config, data_schema, id, dataset_id, action: "edit" }) - await DatasourceDraft.update(datasourcePayload, { where: { id: _.get(datasourcePayload, "id") }, transaction: transact }) + await DatasourceDraft.update(datasourcePayload, { where: { id: _.get(datasourcePayload, "id") }}) } - await DatasetDraft.update(updatedPayload, { where: { id: dataset_id }, transaction: transact }) + await DatasetDraft.update(updatedPayload, { where: { id: dataset_id }}) - await transact.commit(); const responsedata = { message: "Dataset is updated successfully", id: dataset_id, version_key: _.get(datasetPayload, "version_key") } logger.info({ apiId, msgid, requestBody, resmsgid, message: `Dataset updated successfully with id:${dataset_id}`, response: responsedata }) ResponseHandler.successResponse(req, res, { status: httpStatus.OK, data: responsedata }); } catch (error: any) { - await transact.rollback(); const code = _.get(error, "code") || errorCode logger.error({ ...error, apiId, code, msgid, requestBody, resmsgid }) let errorMessage = error; @@ -133,22 +129,22 @@ const datasetUpdate = async (req: Request, res: Response) => { } } -const manageTransformations = async (transformations: Record, datasetId: string, transact: any) => { +const manageTransformations = async (transformations: Record, datasetId: string) => { if (transformations) { const transformationConfigs = await getTransformationConfigs(transformations, datasetId); if (transformationConfigs) { const { addTransformation, updateTransformation, deleteTransformation } = transformationConfigs; if (!_.isEmpty(addTransformation)) { - await DatasetTransformationsDraft.bulkCreate(addTransformation, { transaction: transact }); + await DatasetTransformationsDraft.bulkCreate(addTransformation); } if (!_.isEmpty(updateTransformation)) { - await Promise.all(updateTransformation.map((record: any) => DatasetTransformationsDraft.update(record, { where: { id: record.id }, transaction: transact }))); + await Promise.all(updateTransformation.map((record: any) => DatasetTransformationsDraft.update(record, { where: { id: record.id }}))); } if (!_.isEmpty(deleteTransformation)) { - await DatasetTransformationsDraft.destroy({ where: { id: deleteTransformation }, transaction: transact }); + await DatasetTransformationsDraft.destroy({ where: { id: deleteTransformation }}); } } } diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetCreate/DatasetCreate.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetCreate/DatasetCreate.spec.ts index 4eb72fcd..09b71821 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetCreate/DatasetCreate.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetCreate/DatasetCreate.spec.ts @@ -55,12 +55,7 @@ describe("DATASET CREATE API", () => { chai.spy.on(DatasetTransformations, "findAll", () => { return Promise.resolve() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) + chai .request(app) @@ -84,9 +79,7 @@ describe("DATASET CREATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve(null) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .post("/v2/datasets/create") @@ -105,9 +98,6 @@ describe("DATASET CREATE API", () => { } it("Dataset creation failure: Invalid request payload provided", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/create") @@ -128,9 +118,7 @@ describe("DATASET CREATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ datavalues: [] }) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .post("/v2/datasets/create") @@ -157,12 +145,6 @@ describe("DATASET CREATE API", () => { chai.spy.on(DatasetDraft, "create", () => { return Promise.resolve({ dataValues: { id: "telemetry" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/create") @@ -183,12 +165,6 @@ describe("DATASET CREATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.reject({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/create") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetDelete.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetDelete.spec.ts index 77c4b206..3dccb0a9 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetDelete.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetDelete.spec.ts @@ -11,7 +11,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import { DatasetTransformationsDraft } from "../../../models/TransformationDraft"; import { DatasetSourceConfigDraft } from "../../../models/DatasetSourceConfigDraft"; import { DatasourceDraft } from "../../../models/DatasourceDraft"; -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); @@ -42,12 +41,6 @@ describe("DATASET STATUS TRANSITION DELETE", () => { chai.spy.on(DatasetDraft, "destroy", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -69,9 +62,6 @@ describe("DATASET STATUS TRANSITION DELETE", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetLive.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetLive.spec.ts index 651d51df..3e3e40bc 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetLive.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetLive.spec.ts @@ -8,7 +8,6 @@ import _ from "lodash"; import { apiId, errorCode } from "../../../controllers/DatasetStatusTransition/DatasetStatusTransition"; import { TestInputsForDatasetStatusTransition } from "./Fixtures"; import { DatasetDraft } from "../../../models/DatasetDraft"; -import { sequelize } from "../../../connections/databaseConnection"; import { commandHttpService } from "../../../connections/commandServiceConnection"; chai.use(spies); @@ -30,12 +29,6 @@ describe("DATASET STATUS TRANSITION LIVE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -57,9 +50,6 @@ describe("DATASET STATUS TRANSITION LIVE", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -83,12 +73,6 @@ describe("DATASET STATUS TRANSITION LIVE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.reject() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -108,9 +92,6 @@ describe("DATASET STATUS TRANSITION LIVE", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ dataset_id: "telemetry", status: "Draft" }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetReadyToPublish.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetReadyToPublish.spec.ts index d966b648..ba77c0a2 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetReadyToPublish.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetReadyToPublish.spec.ts @@ -8,7 +8,6 @@ import _ from "lodash"; import { apiId } from "../../../controllers/DatasetStatusTransition/DatasetStatusTransition"; import { TestInputsForDatasetStatusTransition } from "./Fixtures"; import { DatasetDraft } from "../../../models/DatasetDraft"; -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); @@ -30,12 +29,6 @@ describe("DATASET STATUS TRANSITION READY TO PUBLISH", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -57,9 +50,6 @@ describe("DATASET STATUS TRANSITION READY TO PUBLISH", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -80,9 +70,6 @@ describe("DATASET STATUS TRANSITION READY TO PUBLISH", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({dataset_id:"telemetry", status:"ReadyToPublish"}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -104,12 +91,6 @@ describe("DATASET STATUS TRANSITION READY TO PUBLISH", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve(TestInputsForDatasetStatusTransition.INVALID_SCHEMA_FOR_READY_TO_PUBLISH) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetRetire.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetRetire.spec.ts index f6fb1f23..ce47c13c 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetRetire.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetRetire.spec.ts @@ -10,7 +10,6 @@ import { TestInputsForDatasetStatusTransition } from "./Fixtures"; import { Dataset } from "../../../models/Dataset"; import { DatasetDraft } from "../../../models/DatasetDraft"; import { DatasetTransformations } from "../../../models/Transformation"; -import { sequelize } from "../../../connections/databaseConnection"; import { DatasetSourceConfig } from "../../../models/DatasetSourceConfig"; import { Datasource } from "../../../models/Datasource"; import { commandHttpService } from "../../../connections/commandServiceConnection"; @@ -53,12 +52,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -101,12 +94,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -149,12 +136,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.resolve({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -176,9 +157,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(Dataset, "findOne", () => { return Promise.resolve() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -199,9 +177,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(Dataset, "findOne", () => { return Promise.resolve({ dataset_id: "telemetry", status: "Retired", type: "dataset" }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -228,12 +203,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(DatasetDraft, "findAll", () => { return Promise.resolve([{ dataset_id: "telemetry", denorm_config: { denorm_fields: [{ dataset_id: "telemetry" }] } }]) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -257,12 +226,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(Dataset, "update", () => { return Promise.reject({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") @@ -300,12 +263,6 @@ describe("DATASET STATUS TRANSITION RETIRE", () => { chai.spy.on(commandHttpService, "post", () => { return Promise.reject({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetStatusTransition.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetStatusTransition.spec.ts index 9a0d8714..ee589998 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetStatusTransition.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetStatusTransition/DatasetStatusTransition.spec.ts @@ -8,7 +8,6 @@ import _ from "lodash"; import { apiId, errorCode } from "../../../controllers/DatasetStatusTransition/DatasetStatusTransition"; import { TestInputsForDatasetStatusTransition } from "./Fixtures"; import { DatasetDraft } from "../../../models/DatasetDraft"; -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); @@ -24,9 +23,7 @@ describe("DATASET STATUS TRANSITION API", () => { }); it("Dataset status transition failure: Invalid request payload provided", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) + chai .request(app) .post("/v2/datasets/status-transition") @@ -47,12 +44,6 @@ describe("DATASET STATUS TRANSITION API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.reject() }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .post("/v2/datasets/status-transition") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDedup.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDedup.spec.ts index a908966a..8d27057e 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDedup.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDedup.spec.ts @@ -8,7 +8,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, requestStructure, validVersionKey } from "./Fixtures"; import { apiId, invalidInputErrCode } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -29,12 +28,6 @@ describe("DATASET DEDUPE CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -61,12 +54,6 @@ describe("DATASET DEDUPE CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -88,9 +75,6 @@ describe("DATASET DEDUPE CONFIG UPDATE", () => { it("Failure: Dedup key not provided when duplicates need to be dropped", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDenorm.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDenorm.spec.ts index 1c8a65d3..268b83c8 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDenorm.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetDenorm.spec.ts @@ -8,7 +8,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, validVersionKey } from "./Fixtures"; import { apiId } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -29,12 +28,6 @@ describe("DATASET DENORM UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -61,12 +54,6 @@ describe("DATASET DENORM UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -98,12 +85,6 @@ describe("DATASET DENORM UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -126,9 +107,6 @@ describe("DATASET DENORM UPDATE", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ status: "Draft", version_key: validVersionKey }) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -156,12 +134,6 @@ describe("DATASET DENORM UPDATE", () => { } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -189,12 +161,6 @@ describe("DATASET DENORM UPDATE", () => { } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetExtraction.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetExtraction.spec.ts index b30ee4e2..4d7c8131 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetExtraction.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetExtraction.spec.ts @@ -8,7 +8,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, requestStructure, validVersionKey } from "./Fixtures"; import { apiId, invalidInputErrCode } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -29,12 +28,6 @@ describe("DATASET EXTRACTION CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -61,12 +54,6 @@ describe("DATASET EXTRACTION CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -86,9 +73,6 @@ describe("DATASET EXTRACTION CONFIG UPDATE", () => { it("Failure: Extraction configs not provided as batch event is true", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTags.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTags.spec.ts index 1039ef6b..90bb6c67 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTags.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTags.spec.ts @@ -8,7 +8,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, validVersionKey } from "./Fixtures"; import { apiId } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -29,12 +28,6 @@ describe("DATASET TAGS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -61,12 +54,6 @@ describe("DATASET TAGS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -93,12 +80,6 @@ describe("DATASET TAGS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -122,12 +103,6 @@ describe("DATASET TAGS UPDATE", () => { id: "telemetry", status: "Draft", version_key: validVersionKey, tags: ["tag3", "tag1"] }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -150,12 +125,6 @@ describe("DATASET TAGS UPDATE", () => { id: "telemetry", status: "Draft", version_key: validVersionKey, tags: ["tag5"] }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTransformation.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTransformation.spec.ts index cb1fd6be..14ae7c5a 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTransformation.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetTransformation.spec.ts @@ -9,7 +9,6 @@ import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, validVersionKey } from "./Fixtures"; import { DatasetTransformationsDraft } from "../../../models/TransformationDraft"; import { apiId } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -36,12 +35,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -74,12 +67,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -112,12 +99,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -154,12 +135,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -191,12 +166,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetTransformationsDraft, "findAll", () => { return Promise.resolve([{ field_key: "key1" }, { field_key: "key3" }]) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -227,12 +196,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetTransformationsDraft, "findAll", () => { return Promise.resolve([{ field_key: "key7" }, { field_key: "key2" }]) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -263,12 +226,6 @@ describe("DATASET TRANSFORMATIONS UPDATE", () => { chai.spy.on(DatasetTransformationsDraft, "findAll", () => { return Promise.resolve([{ field_key: "key7" }, { field_key: "key3" }]) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetUpdate.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetUpdate.spec.ts index f95e587c..d4d2f921 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetUpdate.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetUpdate.spec.ts @@ -9,7 +9,6 @@ import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, requestStructure, validVersionKey } from "./Fixtures"; import { DatasetTransformationsDraft } from "../../../models/TransformationDraft"; import { apiId, errorCode, invalidInputErrCode } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; import { DatasourceDraft } from "../../../models/DatasourceDraft"; import { Dataset } from "../../../models/Dataset"; import { DatasetTransformations } from "../../../models/Transformation"; @@ -31,12 +30,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -55,12 +48,6 @@ describe("DATASET UPDATE API", () => { }); it("Dataset updation success: When full request payload provided", (done) => { - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ id: "telemetry", status: "Draft", type: "dataset", version_key: validVersionKey, tags: ["tag1", "tag2"], denorm_config: { @@ -122,9 +109,7 @@ describe("DATASET UPDATE API", () => { }); it("Dataset updation failure: When no fields with dataset_id is provided in the request payload", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .patch("/v2/datasets/update") @@ -145,9 +130,7 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve(null) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .patch("/v2/datasets/update") @@ -168,9 +151,7 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ id: "telemetry", status: "Draft", version_key: "1813444815918", api_version: "v2" }) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .patch("/v2/datasets/update") @@ -191,9 +172,7 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ status: "Live" }) }) - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .patch("/v2/datasets/update") @@ -214,12 +193,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "findOne", () => { return Promise.reject({}) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -249,12 +222,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -273,9 +240,7 @@ describe("DATASET UPDATE API", () => { }); it("Failure: Failed to update the dataset name", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) + chai .request(app) .patch("/v2/datasets/update") @@ -314,12 +279,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -352,12 +311,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -376,12 +329,6 @@ describe("DATASET UPDATE API", () => { }); it("Failure: When timestamp key does not exist in the data schema", (done) => { - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "rollback", () => { - return Promise.resolve({}) - }) chai.spy.on(DatasetDraft, "findOne", () => { return Promise.resolve({ id: "telemetry", status: "Draft", version_key: validVersionKey, type: "dataset" @@ -422,9 +369,6 @@ describe("DATASET UPDATE API", () => { }); it("Failure: Failed to update data schema", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -457,12 +401,6 @@ describe("DATASET UPDATE API", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -481,9 +419,6 @@ describe("DATASET UPDATE API", () => { }); it("Failure: Failed to update dataset config", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") diff --git a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetValidation.spec.ts b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetValidation.spec.ts index 75a10e9e..a56444ae 100644 --- a/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetValidation.spec.ts +++ b/api-service/src/v2/tests/DatasetManagement/DatasetUpdate/DatasetValidation.spec.ts @@ -8,7 +8,6 @@ import { DatasetDraft } from "../../../models/DatasetDraft"; import _ from "lodash"; import { TestInputsForDatasetUpdate, msgid, requestStructure, validVersionKey } from "./Fixtures"; import { apiId, invalidInputErrCode } from "../../../controllers/DatasetUpdate/DatasetUpdate" -import { sequelize } from "../../../connections/databaseConnection"; chai.use(spies); chai.should(); @@ -29,12 +28,6 @@ describe("DATASET VALIDATION CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -61,12 +54,6 @@ describe("DATASET VALIDATION CONFIG UPDATE", () => { chai.spy.on(DatasetDraft, "update", () => { return Promise.resolve({ dataValues: { id: "telemetry", message: "Dataset is updated successfully" } }) }) - const t = chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) - chai.spy.on(t, "commit", () => { - return Promise.resolve({}) - }) chai .request(app) .patch("/v2/datasets/update") @@ -86,9 +73,6 @@ describe("DATASET VALIDATION CONFIG UPDATE", () => { it("Failure: Validation configs not provided as validation is true", (done) => { - chai.spy.on(sequelize, "transaction", () => { - return Promise.resolve(sequelize.transaction) - }) chai .request(app) .patch("/v2/datasets/update") From 1679a21e7523e9efec24426eefe5a5ef0c9c2eff Mon Sep 17 00:00:00 2001 From: JeraldJF Date: Tue, 11 Jun 2024 18:00:35 +0530 Subject: [PATCH 2/2] Sanketika-Obsrv/issue-tracker#234: lint fixes --- .../DatasetStatusTransition/DatasetStatusTransition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts b/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts index eafbe789..96e655cf 100644 --- a/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts +++ b/api-service/src/v2/controllers/DatasetStatusTransition/DatasetStatusTransition.ts @@ -146,7 +146,7 @@ const deleteDataset = async (configs: Record) => { } const deleteDraftRecords = async (config: Record) => { - const { dataset_id, transact } = config; + const { dataset_id } = config; await DatasetTransformationsDraft.destroy({ where: { dataset_id } }) await DatasetSourceConfigDraft.destroy({ where: { dataset_id } }) await DatasourceDraft.destroy({ where: { dataset_id } })