mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 23:49:27 +08:00
refactor(server): refine types
This commit is contained in:
parent
a9cc8a17fa
commit
77af3154cf
@ -28,5 +28,5 @@ export interface IPubSubAdapter {
|
||||
close(): Promise<any>;
|
||||
subscribe(channel: string, callback: PubSubCallback): Promise<any>;
|
||||
unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
|
||||
publish(channel: string, message: any): Promise<any>;
|
||||
publish(channel: string, message: string): Promise<any>;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import ws from 'ws';
|
||||
export { MockDatabase, mockDatabase } from '@nocobase/database';
|
||||
export { default as supertest } from 'supertest';
|
||||
export * from './memory-pub-sub-adapter';
|
||||
export * from './mock-cluster';
|
||||
export * from './mock-isolated-cluster';
|
||||
export * from './mock-server';
|
||||
|
||||
export const pgOnly: () => any = () => (process.env.DB_DIALECT == 'postgres' ? describe : describe.skip);
|
||||
|
@ -14,19 +14,19 @@ import { getPortPromise } from 'portfinder';
|
||||
import { uid } from '@nocobase/utils';
|
||||
import { createMockServer } from './mock-server';
|
||||
|
||||
type ClusterOptions = {
|
||||
type IsolatedClusterOptions = {
|
||||
script?: string;
|
||||
env?: Record<string, any>;
|
||||
plugins?: string[];
|
||||
instances?: number;
|
||||
};
|
||||
|
||||
export class MockCluster {
|
||||
export class MockIsolatedCluster {
|
||||
private script = `${process.env.APP_PACKAGE_ROOT}/src/index.ts`;
|
||||
private processes = [];
|
||||
private mockApp;
|
||||
|
||||
constructor(private options: ClusterOptions = {}) {
|
||||
constructor(private options: IsolatedClusterOptions = {}) {
|
||||
if (options.script) {
|
||||
this.script = options.script;
|
||||
}
|
@ -279,12 +279,17 @@ export type MockClusterOptions = MockServerOptions & {
|
||||
appName?: string;
|
||||
};
|
||||
|
||||
export type MockCluster = {
|
||||
nodes: MockServer[];
|
||||
destroy: () => Promise<void>;
|
||||
};
|
||||
|
||||
export async function createMockCluster({
|
||||
number = 2,
|
||||
clusterName = `cluster_${uid()}`,
|
||||
appName = `app_${uid()}`,
|
||||
...options
|
||||
}: MockClusterOptions = {}) {
|
||||
}: MockClusterOptions = {}): Promise<MockCluster> {
|
||||
const nodes: MockServer[] = [];
|
||||
let dbOptions;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user