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


Quelle  status.scan.config-shared.test.ts

  Sprache: JAVA
 

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

import { beforeEach, describe, expect, it, vi } from "vitest";
import {
  loadStatusScanCommandConfig,
  resolveStatusScanColdStart,
  shouldSkipStatusScanMissingConfigFastPath,
} from "./status.scan.config-shared.js";

const mocks = vi.hoisted(() => ({
  resolveConfigPath: vi.fn(),
}));

vi.mock("../config/paths.js", () => ({
  resolveConfigPath: mocks.resolveConfigPath,
}));

describe("status.scan.config-shared", () => {
  beforeEach(() => {
    vi.clearAllMocks();
    mocks.resolveConfigPath.mockReturnValue(
      `/tmp/openclaw-status-scan-config-shared-missing-${process.pid}.json`,
    );
  });

  it("detects the test fast-path env toggle", () => {
    expect(shouldSkipStatusScanMissingConfigFastPath({ ...process.env, VITEST: "true" })).toBe(
      true,
    );
    expect(shouldSkipStatusScanMissingConfigFastPath({ ...process.env, NODE_ENV: "test" })).toBe(
      true,
    );
    expect(shouldSkipStatusScanMissingConfigFastPath({})).toBe(false);
  });

  it("treats missing config as cold-start when fast-path bypass is disabled", () => {
    expect(resolveStatusScanColdStart({ env: {}, allowMissingConfigFastPath: false })).toBe(true);
  });

  it("skips read/resolve on fast-json cold-start outside tests", async () => {
    const readBestEffortConfig = vi.fn(async () => ({ channels: { quietchat: {} } }));
    const resolveConfig = vi.fn(async () => ({
      resolvedConfig: { channels: { quietchat: {} } },
      diagnostics: ["resolved"],
    }));

    const result = await loadStatusScanCommandConfig({
      commandName: "status --json",
      readBestEffortConfig,
      resolveConfig,
      env: {},
      allowMissingConfigFastPath: true,
    });

    expect(readBestEffortConfig).not.toHaveBeenCalled();
    expect(resolveConfig).not.toHaveBeenCalled();
    expect(result).toEqual({
      coldStart: true,
      sourceConfig: {},
      resolvedConfig: {},
      secretDiagnostics: [],
    });
  });

  it("still reads and resolves during tests even when the config path is missing", async () => {
    const sourceConfig = { channels: { quietchat: {} } };
    const resolvedConfig = { channels: { quietchat: {} } };
    const readBestEffortConfig = vi.fn(async () => sourceConfig);
    const resolveConfig = vi.fn(async () => ({
      resolvedConfig,
      diagnostics: ["resolved"],
    }));

    const result = await loadStatusScanCommandConfig({
      commandName: "status --json",
      readBestEffortConfig,
      resolveConfig,
      env: { VITEST: "true" },
      allowMissingConfigFastPath: true,
    });

    expect(readBestEffortConfig).toHaveBeenCalled();
    expect(resolveConfig).toHaveBeenCalledWith(sourceConfig);
    expect(result).toEqual({
      coldStart: false,
      sourceConfig,
      resolvedConfig,
      secretDiagnostics: ["resolved"],
    });
  });
});

¤ Dauer der Verarbeitung: 0.9 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge