Skip to content

Commit

Permalink
Move check related factories to dedicated file
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonkopliku committed Feb 5, 2025
1 parent 2901893 commit ba7dc72
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 56 deletions.
57 changes: 57 additions & 0 deletions assets/js/lib/test-utils/factories/checks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { faker } from '@faker-js/faker';
import { Factory } from 'fishery';
import { EXPECT, EXPECT_ENUM, EXPECT_SAME } from '@lib/model';

export const catalogExpectExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT,
expression: faker.lorem.sentence(),
})
);

export const catalogExpectSameExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT_SAME,
expression: faker.lorem.sentence(),
})
);

export const catalogExpectEnumExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT_ENUM,
expression: faker.lorem.sentence(),
})
);

export const catalogConditionFactory = Factory.define(() => ({
value: faker.lorem.word(),
expression: faker.lorem.sentence(),
}));

export const catalogValueFactory = Factory.define(() => ({
name: faker.string.uuid(),
default: faker.lorem.word(),
customizable: faker.datatype.boolean(),
conditions: catalogConditionFactory.buildList(2),
}));

export const catalogCheckFactory = Factory.define(() => ({
id: faker.string.uuid(),
name: faker.animal.cat(),
group: faker.animal.cat(),
description: faker.lorem.paragraph(),
remediation: faker.lorem.paragraph(),
metadata: null,
values: catalogValueFactory.buildList(3),
expectations: catalogExpectExpectationFactory.buildList(3),
customizable: faker.datatype.boolean(),
}));

export const catalogFactory = Factory.define(() => ({
loading: faker.datatype.boolean(),
catalog: catalogCheckFactory.build(),
error: null,
}));
57 changes: 1 addition & 56 deletions assets/js/lib/test-utils/factories/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { faker } from '@faker-js/faker';
import { Factory } from 'fishery';

import { EXPECT, EXPECT_ENUM, EXPECT_SAME } from '@lib/model';

export * from './executions';
export * from './hosts';
export * from './sapSystems';
Expand All @@ -11,6 +9,7 @@ export * from './databases';
export * from './relevantPatches';
export * from './advisoryErrata';
export * from './users';
export * from './checks';

export const randomObjectFactory = Factory.define(({ transientParams }) => {
const depth = transientParams.depth || 2;
Expand Down Expand Up @@ -71,60 +70,6 @@ export const healthSummaryFactory = Factory.define(() => ({
tenant: generateSid(),
}));

export const catalogExpectExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT,
expression: faker.lorem.sentence(),
})
);

export const catalogExpectSameExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT_SAME,
expression: faker.lorem.sentence(),
})
);

export const catalogExpectEnumExpectationFactory = Factory.define(
({ sequence }) => ({
name: `${faker.lorem.word()}_${sequence}`,
type: EXPECT_ENUM,
expression: faker.lorem.sentence(),
})
);

export const catalogConditionFactory = Factory.define(() => ({
value: faker.lorem.word(),
expression: faker.lorem.sentence(),
}));

export const catalogValueFactory = Factory.define(() => ({
name: faker.string.uuid(),
default: faker.lorem.word(),
customizable: faker.datatype.boolean(),
conditions: catalogConditionFactory.buildList(2),
}));

export const catalogCheckFactory = Factory.define(() => ({
id: faker.string.uuid(),
name: faker.animal.cat(),
group: faker.animal.cat(),
description: faker.lorem.paragraph(),
remediation: faker.lorem.paragraph(),
metadata: null,
values: catalogValueFactory.buildList(3),
expectations: catalogExpectExpectationFactory.buildList(3),
customizable: faker.datatype.boolean(),
}));

export const catalogFactory = Factory.define(() => ({
loading: faker.datatype.boolean(),
catalog: catalogCheckFactory.build(),
error: null,
}));

export const aboutFactory = Factory.define(() => ({
sles_subscriptions: faker.number.int(),
version: faker.system.networkInterface(),
Expand Down

0 comments on commit ba7dc72

Please sign in to comment.