Skip to content

Commit 9616950

Browse files
Test: Move test function to test package: createDataStoreFactory (#24395)
The function createDataStoreFactory is only used in test and doesn't make sense out of a test context. So, moving this function to a better location in a test package.
1 parent 18d5530 commit 9616950

File tree

6 files changed

+32
-36
lines changed

6 files changed

+32
-36
lines changed

packages/runtime/runtime-utils/src/dataStoreHelpers.ts

-31
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55

66
import { IRequest, IResponse } from "@fluidframework/core-interfaces";
77
import { assert } from "@fluidframework/core-utils/internal";
8-
import {
9-
IFluidDataStoreFactory,
10-
IFluidDataStoreRegistry,
11-
IProvideFluidDataStoreRegistry,
12-
} from "@fluidframework/runtime-definitions/internal";
138
import { generateErrorWithStack } from "@fluidframework/telemetry-utils/internal";
149

1510
interface IResponseException extends Error {
@@ -104,29 +99,3 @@ export function createResponseError(
10499
headers,
105100
};
106101
}
107-
108-
/**
109-
* @internal
110-
*/
111-
export type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;
112-
113-
/**
114-
* @internal
115-
*/
116-
export function createDataStoreFactory(
117-
type: string,
118-
factory: Factory | Promise<Factory>,
119-
): IFluidDataStoreFactory & IFluidDataStoreRegistry {
120-
return {
121-
type,
122-
get IFluidDataStoreFactory() {
123-
return this;
124-
},
125-
get IFluidDataStoreRegistry() {
126-
return this;
127-
},
128-
instantiateDataStore: async (context, existing) =>
129-
(await factory).instantiateDataStore(context, existing),
130-
get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
131-
};
132-
}

packages/runtime/runtime-utils/src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
export { generateHandleContextPath } from "./dataStoreHandleContextUtils.js";
77
export {
88
create404Response,
9-
createDataStoreFactory,
109
createResponseError,
1110
exceptionToResponse,
12-
Factory,
1311
responseToException,
1412
} from "./dataStoreHelpers.js";
1513
export {

packages/test/local-server-tests/src/test/opsOnReconnect.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import {
2525
} from "@fluidframework/local-driver/internal";
2626
import { SharedDirectory, type ISharedMap, SharedMap } from "@fluidframework/map/internal";
2727
import { FlushMode, IEnvelope } from "@fluidframework/runtime-definitions/internal";
28-
import { createDataStoreFactory } from "@fluidframework/runtime-utils/internal";
2928
import { SharedString } from "@fluidframework/sequence/internal";
3029
import {
3130
ILocalDeltaConnectionServer,
3231
LocalDeltaConnectionServer,
3332
} from "@fluidframework/server-local-server";
33+
import { createDataStoreFactory } from "@fluidframework/test-utils/internal";
3434
import {
3535
createAndAttachContainerUsingProps,
3636
ITestFluidObject,

packages/test/test-end-to-end-tests/src/test/deRehydrateContainerTests.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import type { SharedMatrix } from "@fluidframework/matrix/internal";
2222
import type { ConsensusOrderedCollection } from "@fluidframework/ordered-collection/internal";
2323
import type { ConsensusRegisterCollection } from "@fluidframework/register-collection/internal";
2424
import { IContainerRuntimeBase } from "@fluidframework/runtime-definitions/internal";
25-
import { createDataStoreFactory } from "@fluidframework/runtime-utils/internal";
2625
import type { SequenceInterval, SharedString } from "@fluidframework/sequence/internal";
26+
import { createDataStoreFactory } from "@fluidframework/test-utils/internal";
2727
import {
2828
ITestFluidObject,
2929
ITestObjectProvider,

packages/test/test-utils/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export {
99
fluidEntryPoint,
1010
LocalCodeLoader,
1111
SupportedExportInterfaces,
12+
Factory,
13+
createDataStoreFactory,
1214
} from "./localCodeLoader.js";
1315
export {
1416
createAndAttachContainer,

packages/test/test-utils/src/localCodeLoader.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/inte
1717
import {
1818
IProvideFluidDataStoreFactory,
1919
IProvideFluidDataStoreRegistry,
20+
type IFluidDataStoreFactory,
21+
type IFluidDataStoreRegistry,
2022
} from "@fluidframework/runtime-definitions/internal";
21-
import { createDataStoreFactory } from "@fluidframework/runtime-utils/internal";
2223

2324
// eslint-disable-next-line import/no-deprecated
2425
import { ContainerRuntimeFactoryWithDefaultDataStore } from "./containerRuntimeFactories.js";
@@ -39,6 +40,32 @@ export type SupportedExportInterfaces = Partial<
3940
*/
4041
export type fluidEntryPoint = SupportedExportInterfaces | IFluidModule;
4142

43+
/**
44+
* @internal
45+
*/
46+
export type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;
47+
48+
/**
49+
* @internal
50+
*/
51+
export function createDataStoreFactory(
52+
type: string,
53+
factory: Factory | Promise<Factory>,
54+
): IFluidDataStoreFactory & IFluidDataStoreRegistry {
55+
return {
56+
type,
57+
get IFluidDataStoreFactory() {
58+
return this;
59+
},
60+
get IFluidDataStoreRegistry() {
61+
return this;
62+
},
63+
instantiateDataStore: async (context, existing) =>
64+
(await factory).instantiateDataStore(context, existing),
65+
get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
66+
};
67+
}
68+
4269
/**
4370
* A simple code loader that caches a mapping of package name to a Fluid entry point.
4471
* On load, it retrieves the entry point matching the package name in the given code details.

0 commit comments

Comments
 (0)