Skip to content

Commit

Permalink
refactor: Remove model in d2
Browse files Browse the repository at this point in the history
  • Loading branch information
tanbowensg committed Jan 4, 2024
1 parent f10cb75 commit 332cc7b
Show file tree
Hide file tree
Showing 80 changed files with 3,781 additions and 633 deletions.
10 changes: 0 additions & 10 deletions packages/refine/.eslintrc.js

This file was deleted.

56 changes: 56 additions & 0 deletions packages/refine/__tests__/plugins/all-plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { UnstructuredList } from 'k8s-api-provider';
import { WorkloadModel } from '../../src/models';
import { ProviderPlugins } from '../../src/plugins';
import { RawDeploymentList, mockGlobalStore } from './mock';

describe('Test Plugins together', () => {
ProviderPlugins.forEach(p => p.init(mockGlobalStore as any));

async function processListByPlugins(list: UnstructuredList) {
let nextList = list;
for (const plugin of ProviderPlugins) {
nextList = await plugin.processData(nextList);
}
return nextList;
}

it('should return deployment model', async () => {
const result = await processListByPlugins(RawDeploymentList as UnstructuredList);
const deploymentModel = result.items[0] as WorkloadModel;
expect(result.items.length).toEqual(2);
expect(deploymentModel.restarts).toEqual(5);
});

it('should return deployment model with relation', async () => {
const result = await processListByPlugins(RawDeploymentList as UnstructuredList);
const deploymentModel = result.items[0] as WorkloadModel;
expect((deploymentModel.metadata as any).relations).toEqual([
{
kind: 'Pod',
apiVersion: 'v1',
type: 'creates',
selector: {
matchLabels: {
'app.kubernetes.io/component': 'controller',
'app.kubernetes.io/instance': 'cert-manager',
'app.kubernetes.io/name': 'cert-manager',
},
},
inbound: false,
},
{
kind: 'Pod',
apiVersion: 'v1',
type: 'creates',
selector: {
matchLabels: {
'app.kubernetes.io/component': 'controller',
'app.kubernetes.io/instance': 'cert-manager',
'app.kubernetes.io/name': 'cert-manager',
},
},
inbound: false,
},
]);
});
});
Loading

0 comments on commit 332cc7b

Please sign in to comment.