Skip to content

Commit

Permalink
test(lib): fix test after introducing phased execution
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Jul 17, 2024
1 parent 5a91cde commit d00e842
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions src/__tests__/if-run/lib/compute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ describe('lib/compute: ', () => {
kind: 'execute',
},
});
const mockGroupByPlugin = () => ({
execute: (inputs: any) => ({children: inputs}),
metadata: {
kind: 'groupby',
},
});
/**
* Compute params.
*/
Expand All @@ -43,28 +37,13 @@ describe('lib/compute: ', () => {
},
pluginStorage: pluginStorage().set('mock', mockExecutePlugin()),
};
const params: ComputeParams = {
// @ts-ignore
context: {
name: 'mock-name',
initialize: {
plugins: {
mock: {
path: 'mockavizta',
method: 'Mockavizta',
},
},
},
},
pluginStorage: pluginStorage().set('mock', mockGroupByPlugin()),
};

describe('compute(): ', () => {
it('computes simple tree with execute plugin.', async () => {
const tree = {
children: {
mockChild: {
pipeline: ['mock'],
pipeline: {compute: ['mock']},
inputs: [
{timestamp: 'mock-timestamp-1', duration: 10},
{timestamp: 'mock-timestamp-2', duration: 10},
Expand All @@ -85,27 +64,32 @@ describe('lib/compute: ', () => {
const tree = {
children: {
mockChild: {
pipeline: ['mock'],
pipeline: {regroup: ['duration']},
inputs: [
{timestamp: 'mock-timestamp-1', duration: 10},
{timestamp: 'mock-timestamp-2', duration: 10},
],
},
},
};
const response = await compute(tree, params);
const expectedResult = mockGroupByPlugin().execute(
tree.children.mockChild.inputs
);
const response = await compute(tree, paramsExecute);
const expectedResponse = {
'10': {
inputs: [
{duration: 10, timestamp: 'mock-timestamp-1'},
{duration: 10, timestamp: 'mock-timestamp-2'},
],
},
};

expect(response.children.mockChild.children).toEqual(expectedResult);
expect(response.children.mockChild.children).toEqual(expectedResponse);
});

it('computes simple tree with defaults and execute plugin.', async () => {
const tree = {
children: {
mockChild: {
pipeline: ['mock'],
pipeline: {compute: ['mock']},
defaults: {
'cpu/name': 'Intel CPU',
},
Expand All @@ -132,7 +116,7 @@ describe('lib/compute: ', () => {
const tree = {
children: {
mockChild1: {
pipeline: ['mock'],
pipeline: {compute: ['mock']},
defaults: {
'cpu/name': 'Intel CPU',
},
Expand All @@ -144,7 +128,7 @@ describe('lib/compute: ', () => {
mockChild2: {
children: {
mockChild21: {
pipeline: ['mock'],
pipeline: {compute: ['mock']},
defaults: {
'cpu/name': 'Intel CPU',
},
Expand Down Expand Up @@ -188,16 +172,17 @@ describe('lib/compute: ', () => {
},
};
const response = await compute(tree, paramsExecute);
const expectedResult: any[] = [];

expect(response.children.mockChild.outputs).toEqual(expectedResult);
expect(response.children.mockChild.outputs).toBeUndefined();
});

it('computes simple tree with defaults and no inputs with execue plugin.', async () => {
const tree = {
children: {
mockChild: {
pipeline: ['mock'],
pipeline: {
compute: ['mock'],
},
defaults: {
carbon: 10,
},
Expand All @@ -215,7 +200,9 @@ describe('lib/compute: ', () => {
const tree = {
children: {
mockChild: {
pipeline: ['mock'],
pipeline: {
compute: ['mock'],
},
config: {
'cpu/name': 'Intel CPU',
},
Expand Down

0 comments on commit d00e842

Please sign in to comment.