Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/plugin-sdk/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 3 kB image not shown  

Quelle  runtime-store.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, test } from "vitest";
import { importFreshModule } from "../../test/helpers/import-fresh.ts";
import { createPluginRuntimeStore } from "./runtime-store.js";

describe("createPluginRuntimeStore", () => {
  test("shares runtime slots for the same plugin id", () => {
    const firstStore = createPluginRuntimeStore<{ value: string }>({
      pluginId: "shared-plugin",
      errorMessage: "shared plugin runtime not initialized",
    });
    const secondStore = createPluginRuntimeStore<{ value: string }>({
      pluginId: "shared-plugin",
      errorMessage: "shared plugin runtime not initialized",
    });

    firstStore.clearRuntime();
    firstStore.setRuntime({ value: "ok" });

    expect(secondStore.getRuntime()).toEqual({ value: "ok" });

    secondStore.clearRuntime();
    expect(firstStore.tryGetRuntime()).toBeNull();
  });

  test("keeps different plugin ids isolated", () => {
    const leftStore = createPluginRuntimeStore<{ value: string }>({
      pluginId: "left-plugin",
      errorMessage: "left runtime not initialized",
    });
    const rightStore = createPluginRuntimeStore<{ value: string }>({
      pluginId: "right-plugin",
      errorMessage: "right runtime not initialized",
    });

    leftStore.clearRuntime();
    rightStore.clearRuntime();
    leftStore.setRuntime({ value: "left" });

    expect(leftStore.getRuntime()).toEqual({ value: "left" });
    expect(rightStore.tryGetRuntime()).toBeNull();
  });

  test("keeps legacy string callers isolated per store", () => {
    const firstStore = createPluginRuntimeStore<{ value: string }>(
      "legacy runtime not initialized",
    );
    const secondStore = createPluginRuntimeStore<{ value: string }>(
      "legacy runtime not initialized",
    );

    firstStore.clearRuntime();
    firstStore.setRuntime({ value: "legacy" });

    expect(firstStore.getRuntime()).toEqual({ value: "legacy" });
    expect(secondStore.tryGetRuntime()).toBeNull();
  });

  test("still supports explicit custom store keys", () => {
    const firstStore = createPluginRuntimeStore<{ value: string }>({
      key: "custom-runtime-key",
      errorMessage: "custom runtime not initialized",
    });
    const secondStore = createPluginRuntimeStore<{ value: string }>({
      key: "custom-runtime-key",
      errorMessage: "custom runtime not initialized",
    });

    firstStore.clearRuntime();
    firstStore.setRuntime({ value: "custom" });

    expect(secondStore.getRuntime()).toEqual({ value: "custom" });
  });

  test("rejects empty plugin ids", () => {
    expect(() =>
      createPluginRuntimeStore({
        pluginId: "   ",
        errorMessage: "runtime not initialized",
      }),
    ).toThrow("pluginId must not be empty");
  });

  test("treats falsy runtime values as initialized", () => {
    const store = createPluginRuntimeStore<number>({
      key: "custom-falsy-runtime-key",
      errorMessage: "runtime not initialized",
    });

    store.clearRuntime();
    store.setRuntime(0);

    expect(store.getRuntime()).toBe(0);
  });

  test("shares runtime slots across duplicate module instances when plugin id matches", async () => {
    const firstModule = await importFreshModule<typeof import("./runtime-store.js")>(
      import.meta.url,
      "./runtime-store.js?scope=runtime-store-a",
    );
    const secondModule = await importFreshModule<typeof import("./runtime-store.js")>(
      import.meta.url,
      "./runtime-store.js?scope=runtime-store-b",
    );
    const firstStore = firstModule.createPluginRuntimeStore<{ value: string }>({
      pluginId: "duplicate-module-plugin",
      errorMessage: "duplicate module runtime not initialized",
    });
    const secondStore = secondModule.createPluginRuntimeStore<{ value: string }>({
      pluginId: "duplicate-module-plugin",
      errorMessage: "duplicate module runtime not initialized",
    });

    firstStore.clearRuntime();
    firstStore.setRuntime({ value: "shared" });

    expect(secondStore.getRuntime()).toEqual({ value: "shared" });
  });
});

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.