diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/package.json b/packages/plugins/@nocobase/plugin-data-source-manager/package.json index 0df8af4552..1e22023709 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/package.json +++ b/packages/plugins/@nocobase/plugin-data-source-manager/package.json @@ -5,7 +5,7 @@ "dependencies": {}, "displayName": "Database source manager ", "displayName.zh-CN": "外部数据源管理", - "description": "Connect external data source to Nocobase", + "description": "Connect external data source to NocoBase", "description.zh-CN": "将外部数据源接入Nocobase", "peerDependencies": { "@nocobase/client": "0.x", diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/__tests__/data-sources.test.ts b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/__tests__/data-sources.test.ts index 93197ac1f1..6f1ed1d790 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/server/__tests__/data-sources.test.ts +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/server/__tests__/data-sources.test.ts @@ -1,4 +1,5 @@ import { createMockServer, MockServer } from '@nocobase/test'; +import { DataSource } from '@nocobase/data-source-manager'; describe('data source', async () => { let app: MockServer; @@ -13,5 +14,33 @@ describe('data source', async () => { await app.destroy(); }); - it('should create data source', async () => {}); + it('should create data source', async () => { + const loadFn = vi.fn(); + + class MockDataSource extends DataSource { + async load(): Promise { + loadFn(); + } + + createCollectionManager(options?: any): any { + return undefined; + } + } + + app.dataSourceManager.factory.register('mock', MockDataSource); + + await app.db.getRepository('dataSources').create({ + values: { + key: 'mockInstance1', + type: 'mock', + displayName: 'Mock', + options: {}, + }, + }); + + expect(loadFn).toBeCalledTimes(1); + + const mockDataSource = app.dataSourceManager.dataSources.get('mockInstance1'); + expect(mockDataSource).toBeInstanceOf(MockDataSource); + }); });