Merge pull request #1753 from automatisch/use-objection-for-factories
refactor: Use objection instead of knex for factories
This commit is contained in:
@@ -42,9 +42,12 @@ describe('GET /api/v1/executions', () => {
|
||||
|
||||
const currentUserExecutionTwo = await createExecution({
|
||||
flowId: currentUserFlow.id,
|
||||
deletedAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
await currentUserExecutionTwo
|
||||
.$query()
|
||||
.patchAndFetch({ deletedAt: new Date().toISOString() });
|
||||
|
||||
await createPermission({
|
||||
action: 'read',
|
||||
subject: 'Execution',
|
||||
@@ -87,9 +90,12 @@ describe('GET /api/v1/executions', () => {
|
||||
|
||||
const anotherUserExecutionTwo = await createExecution({
|
||||
flowId: anotherUserFlow.id,
|
||||
deletedAt: new Date().toISOString(),
|
||||
});
|
||||
|
||||
await anotherUserExecutionTwo
|
||||
.$query()
|
||||
.patchAndFetch({ deletedAt: new Date().toISOString() });
|
||||
|
||||
await createPermission({
|
||||
action: 'read',
|
||||
subject: 'Execution',
|
||||
|
@@ -17,9 +17,7 @@ export const createAppAuthClient = async (params = {}) => {
|
||||
params.formattedAuthDefaults =
|
||||
params?.formattedAuthDefaults || formattedAuthDefaults;
|
||||
|
||||
const appAuthClient = await AppAuthClient.query()
|
||||
.insert(params)
|
||||
.returning('*');
|
||||
const appAuthClient = await AppAuthClient.query().insertAndFetch(params);
|
||||
|
||||
return appAuthClient;
|
||||
};
|
||||
|
@@ -3,7 +3,7 @@ import AppConfig from '../../src/models/app-config.js';
|
||||
export const createAppConfig = async (params = {}) => {
|
||||
params.key = params?.key || 'gitlab';
|
||||
|
||||
const appConfig = await AppConfig.query().insert(params).returning('*');
|
||||
const appConfig = await AppConfig.query().insertAndFetch(params);
|
||||
|
||||
return appConfig;
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@ export const createConfig = async (params = {}) => {
|
||||
value: params?.value || { data: 'sampleConfig' },
|
||||
};
|
||||
|
||||
const config = await Config.query().insert(configData).returning('*');
|
||||
const config = await Config.query().insertAndFetch(configData);
|
||||
|
||||
return config;
|
||||
};
|
||||
|
@@ -9,9 +9,7 @@ export const createExecutionStep = async (params = {}) => {
|
||||
params.dataIn = params?.dataIn || { dataIn: 'dataIn' };
|
||||
params.dataOut = params?.dataOut || { dataOut: 'dataOut' };
|
||||
|
||||
const executionStep = await ExecutionStep.query()
|
||||
.insert(params)
|
||||
.returning('*');
|
||||
const executionStep = await ExecutionStep.query().insertAndFetch(params);
|
||||
|
||||
return executionStep;
|
||||
};
|
||||
|
@@ -4,10 +4,8 @@ import { createFlow } from './flow';
|
||||
export const createExecution = async (params = {}) => {
|
||||
params.flowId = params?.flowId || (await createFlow()).id;
|
||||
params.testRun = params?.testRun || false;
|
||||
params.createdAt = params?.createdAt || new Date().toISOString();
|
||||
params.updatedAt = params?.updatedAt || new Date().toISOString();
|
||||
|
||||
const execution = await Execution.query().insert(params).returning('*');
|
||||
const execution = await Execution.query().insertAndFetch(params);
|
||||
|
||||
return execution;
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@ export const createFlow = async (params = {}) => {
|
||||
params.createdAt = params?.createdAt || new Date().toISOString();
|
||||
params.updatedAt = params?.updatedAt || new Date().toISOString();
|
||||
|
||||
const flow = await Flow.query().insert(params).returning('*');
|
||||
const flow = await Flow.query().insertAndFetch(params);
|
||||
|
||||
return flow;
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@ export const createPermission = async (params = {}) => {
|
||||
params.subject = params?.subject || 'User';
|
||||
params.conditions = params?.conditions || ['isCreator'];
|
||||
|
||||
const permission = await Permission.query().insert(params).returning('*');
|
||||
const permission = await Permission.query().insertAndFetch(params);
|
||||
|
||||
return permission;
|
||||
};
|
||||
|
@@ -4,7 +4,7 @@ export const createRole = async (params = {}) => {
|
||||
params.name = params?.name || 'Viewer';
|
||||
params.key = params?.key || 'viewer';
|
||||
|
||||
const role = await Role.query().insert(params).returning('*');
|
||||
const role = await Role.query().insertAndFetch(params);
|
||||
|
||||
return role;
|
||||
};
|
||||
|
@@ -25,9 +25,9 @@ export const createSamlAuthProvider = async (params = {}) => {
|
||||
params.defaultRoleId = params?.defaultRoleId || (await createRole()).id;
|
||||
params.active = params?.active || true;
|
||||
|
||||
const samlAuthProvider = await SamlAuthProvider.query()
|
||||
.insert(params)
|
||||
.returning('*');
|
||||
const samlAuthProvider = await SamlAuthProvider.query().insertAndFetch(
|
||||
params
|
||||
);
|
||||
|
||||
return samlAuthProvider;
|
||||
};
|
||||
|
@@ -15,7 +15,7 @@ export const createSubscription = async (params = {}) => {
|
||||
params.nextBillDate =
|
||||
params?.nextBillDate || DateTime.now().plus({ days: 30 }).toISODate();
|
||||
|
||||
const subscription = await Subscription.query().insert(params).returning('*');
|
||||
const subscription = await Subscription.query().insertAndFetch(params);
|
||||
|
||||
return subscription;
|
||||
};
|
||||
|
@@ -8,7 +8,7 @@ export const createUser = async (params = {}) => {
|
||||
params.email = params?.email || faker.internet.email();
|
||||
params.password = params?.password || faker.internet.password();
|
||||
|
||||
const user = await User.query().insert(params).returning('*');
|
||||
const user = await User.query().insertAndFetch(params);
|
||||
|
||||
return user;
|
||||
};
|
||||
|
Reference in New Issue
Block a user