feat(FN-4460): complete Step 2 — route CLI finalize via task store accessor
Fusion-Task-Id: FN-4460 Fusion-Task-Lineage: 68204f34-f9ab-4714-936f-0bf4472432f0
This commit is contained in:
@@ -6,6 +6,7 @@ import { join } from "node:path";
|
||||
const previewPlan = vi.fn();
|
||||
const finalize = vi.fn();
|
||||
const init = vi.fn();
|
||||
const getExperimentSessionStore = vi.fn(() => ({}));
|
||||
|
||||
const mockErrors = vi.hoisted(() => ({
|
||||
CherryPickConflictError: class extends Error {
|
||||
@@ -17,8 +18,7 @@ const mockErrors = vi.hoisted(() => ({
|
||||
}));
|
||||
|
||||
vi.mock("@fusion/core", () => ({
|
||||
createDatabase: vi.fn(() => ({ init })),
|
||||
ExperimentSessionStore: vi.fn(),
|
||||
TaskStore: vi.fn(() => ({ init, getExperimentSessionStore })),
|
||||
}));
|
||||
|
||||
vi.mock("@fusion/engine", () => ({
|
||||
@@ -38,6 +38,7 @@ describe("runExperimentFinalize", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
init.mockResolvedValue(undefined);
|
||||
getExperimentSessionStore.mockReturnValue({});
|
||||
});
|
||||
|
||||
it("dry-run calls previewPlan and not finalize", async () => {
|
||||
@@ -46,6 +47,7 @@ describe("runExperimentFinalize", () => {
|
||||
|
||||
await runExperimentFinalize({ sessionId: "EXP-1", dryRun: true });
|
||||
|
||||
expect(getExperimentSessionStore).toHaveBeenCalled();
|
||||
expect(previewPlan).toHaveBeenCalledWith({ sessionId: "EXP-1", integrationBranch: undefined });
|
||||
expect(finalize).not.toHaveBeenCalled();
|
||||
expect(logSpy).toHaveBeenCalled();
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import {
|
||||
createDatabase,
|
||||
ExperimentSessionStore,
|
||||
} from "@fusion/core";
|
||||
import { TaskStore } from "@fusion/core";
|
||||
import {
|
||||
defaultGitOps,
|
||||
ExperimentFinalizeBranchExistsError,
|
||||
@@ -72,11 +69,11 @@ export async function runExperimentFinalize(options: ExperimentFinalizeOptions):
|
||||
try {
|
||||
const project = options.projectName ? await resolveProject(options.projectName) : undefined;
|
||||
const projectRoot = project?.projectPath ?? process.cwd();
|
||||
const db = createDatabase(resolve(projectRoot, ".fusion"));
|
||||
await db.init();
|
||||
const store = new ExperimentSessionStore(db);
|
||||
const taskStore = new TaskStore(projectRoot);
|
||||
await taskStore.init();
|
||||
const sessionStore = taskStore.getExperimentSessionStore();
|
||||
const service = new ExperimentFinalizeService({
|
||||
store,
|
||||
store: sessionStore,
|
||||
git: defaultGitOps(projectRoot),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user