




















@@ -25,12 +25,12 @@ const spawnState = vi.hoisted(() => ({
2525}));
26262727const registryMocks = vi.hoisted(() => ({
28-readRegistry: vi.fn(),
28+readRegistryEntry: vi.fn(),
2929updateRegistry: vi.fn(),
3030}));
31313232vi.mock("./registry.js", () => ({
33-readRegistry: registryMocks.readRegistry,
33+readRegistryEntry: registryMocks.readRegistryEntry,
3434updateRegistry: registryMocks.updateRegistry,
3535}));
3636@@ -100,7 +100,7 @@ let ensureSandboxContainer: typeof import("./docker.js").ensureSandboxContainer;
100100async function loadFreshDockerModuleForTest() {
101101vi.resetModules();
102102vi.doMock("./registry.js", () => ({
103-readRegistry: registryMocks.readRegistry,
103+readRegistryEntry: registryMocks.readRegistryEntry,
104104updateRegistry: registryMocks.updateRegistry,
105105}));
106106vi.doMock("node:child_process", async () => createChildProcessMock());
@@ -185,7 +185,7 @@ describe("ensureSandboxContainer config-hash recreation", () => {
185185spawnState.calls.length = 0;
186186spawnState.inspectRunning = true;
187187spawnState.labelHash = "";
188-registryMocks.readRegistry.mockClear();
188+registryMocks.readRegistryEntry.mockClear();
189189registryMocks.updateRegistry.mockClear();
190190registryMocks.updateRegistry.mockResolvedValue(undefined);
191191await loadFreshDockerModuleForTest();
@@ -213,17 +213,13 @@ describe("ensureSandboxContainer config-hash recreation", () => {
213213expect(newHash).not.toBe(oldHash);
214214215215spawnState.labelHash = oldHash;
216-registryMocks.readRegistry.mockResolvedValue({
217-entries: [
218-{
219-containerName: "oc-test-shared",
220-sessionKey: "shared",
221-createdAtMs: 1,
222-lastUsedAtMs: 0,
223-image: newCfg.docker.image,
224-configHash: oldHash,
225-},
226-],
216+registryMocks.readRegistryEntry.mockResolvedValue({
217+containerName: "oc-test-shared",
218+sessionKey: "shared",
219+createdAtMs: 1,
220+lastUsedAtMs: 0,
221+image: newCfg.docker.image,
222+configHash: oldHash,
227223});
228224229225const containerName = await ensureSandboxContainer({
@@ -269,17 +265,13 @@ describe("ensureSandboxContainer config-hash recreation", () => {
269265270266spawnState.inspectRunning = false;
271267spawnState.labelHash = "stale-hash";
272-registryMocks.readRegistry.mockResolvedValue({
273-entries: [
274-{
275-containerName: "oc-test-shared",
276-sessionKey: "shared",
277-createdAtMs: 1,
278-lastUsedAtMs: 0,
279-image: cfg.docker.image,
280-configHash: "stale-hash",
281-},
282-],
268+registryMocks.readRegistryEntry.mockResolvedValue({
269+containerName: "oc-test-shared",
270+sessionKey: "shared",
271+createdAtMs: 1,
272+lastUsedAtMs: 0,
273+image: cfg.docker.image,
274+configHash: "stale-hash",
283275});
284276285277const createCall = await ensureSandboxCreateCallForTest({ cfg, workspaceDir });
@@ -304,7 +296,7 @@ describe("ensureSandboxContainer config-hash recreation", () => {
304296305297spawnState.inspectRunning = false;
306298spawnState.labelHash = "";
307-registryMocks.readRegistry.mockResolvedValue({ entries: [] });
299+registryMocks.readRegistryEntry.mockResolvedValue(null);
308300registryMocks.updateRegistry.mockResolvedValue(undefined);
309301310302const createCall = await ensureSandboxCreateCallForTest({ cfg, workspaceDir });
@@ -320,7 +312,7 @@ describe("ensureSandboxContainer config-hash recreation", () => {
320312321313spawnState.inspectRunning = false;
322314spawnState.labelHash = "";
323-registryMocks.readRegistry.mockResolvedValue({ entries: [] });
315+registryMocks.readRegistryEntry.mockResolvedValue(null);
324316325317const createCall = await ensureSandboxCreateCallForTest({ cfg, workspaceDir });
326318expect(createCall.args).toContain(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。