Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  cleanup.test.ts

  Sprache: JAVA
 

import { afterEach, describe, expect, it, vi } from "vitest";
import { __testing, clearSessionQueues } from "./cleanup.js";

const followupQueueMocks = vi.hoisted(() => ({
  clearFollowupDrainCallback: vi.fn(),
  clearFollowupQueue: vi.fn(() => 2),
}));

const commandQueueMocks = vi.hoisted(() => ({
  clearCommandLane: vi.fn(() => 3),
}));

vi.mock("./drain.js", () => ({
  clearFollowupDrainCallback: followupQueueMocks.clearFollowupDrainCallback,
}));

vi.mock("./state.js", () => ({
  clearFollowupQueue: followupQueueMocks.clearFollowupQueue,
}));

vi.mock("../../../process/command-queue.js", () => ({
  clearCommandLane: commandQueueMocks.clearCommandLane,
}));

vi.mock("../../../agents/pi-embedded-runner/lanes.js", () => ({
  resolveEmbeddedSessionLane: (key: string) => `session:${key.trim() || "main"}`,
}));

describe("clearSessionQueues", () => {
  afterEach(() => {
    __testing.resetDepsForTests();
    followupQueueMocks.clearFollowupDrainCallback.mockReset();
    followupQueueMocks.clearFollowupQueue.mockReset().mockReturnValue(2);
    commandQueueMocks.clearCommandLane.mockReset().mockReturnValue(3);
  });

  it("falls back to default runtime deps when injected deps are invalid", () => {
    __testing.setDepsForTests({
      resolveEmbeddedSessionLane: undefined,
      clearCommandLane: undefined,
    });

    const result = clearSessionQueues(["alpha"]);

    expect(result).toEqual({
      followupCleared: 2,
      laneCleared: 3,
      keys: ["alpha"],
    });
    expect(followupQueueMocks.clearFollowupQueue).toHaveBeenCalledWith("alpha");
    expect(followupQueueMocks.clearFollowupDrainCallback).toHaveBeenCalledWith("alpha");
    expect(commandQueueMocks.clearCommandLane).toHaveBeenCalledWith("session:alpha");
  });

  it("falls back at call time when a test mutates deps to non-functions", () => {
    __testing.setDepsForTests({
      resolveEmbeddedSessionLane: ((key: string) => `custom:${key}`) as never,
      clearCommandLane: ((lane: string) => (lane === "custom:alpha" ? 7 : 0)) as never,
    });
    (
      __testing as {
        setDepsForTests: (deps: Partial<Record<string, unknown>> | undefined) => void;
      }
    ).setDepsForTests({
      resolveEmbeddedSessionLane: "broken",
      clearCommandLane: "broken",
    });

    const result = clearSessionQueues(["alpha"]);

    expect(result).toEqual({
      followupCleared: 2,
      laneCleared: 3,
      keys: ["alpha"],
    });
    expect(commandQueueMocks.clearCommandLane).toHaveBeenCalledWith("session:alpha");
  });
});

Messung V0.5 in Prozent
C=97 H=93 G=94

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik