Files
oh-my-pi/packages/coding-agent/test/tiny-worker-env.test.ts
T
can1357 668faabfd2 feat(tiny): added providers.tinyModelDevice and tinyModelDtype settings
- Added persistent settings in the Providers tab for ONNX execution provider and quantization/precision, replacing env-var-only configuration.
- PI_TINY_DEVICE and PI_TINY_DTYPE env vars still override the matching setting at spawn time.
- Added tinyWorkerEnvOverlay to map settings onto worker env without clobbering explicit env vars.
- Updated docs and tests to reflect the new setting-first resolution order.
2026-05-31 02:14:58 +02:00

22 lines
896 B
TypeScript

import { describe, expect, it } from "bun:test";
import { tinyWorkerEnvOverlay } from "../src/tiny/title-client";
describe("tinyWorkerEnvOverlay", () => {
it("maps non-default settings onto the worker env vars when neither is already set", () => {
expect(tinyWorkerEnvOverlay({}, "cuda", "fp16")).toEqual({
PI_TINY_DEVICE: "cuda",
PI_TINY_DTYPE: "fp16",
});
});
it("lets a present env var win over the persisted setting", () => {
expect(tinyWorkerEnvOverlay({ PI_TINY_DEVICE: "cpu" }, "cuda", "fp16")).toEqual({ PI_TINY_DTYPE: "fp16" });
expect(tinyWorkerEnvOverlay({ PI_TINY_DTYPE: "q8" }, "cuda", "fp16")).toEqual({ PI_TINY_DEVICE: "cuda" });
});
it("omits a var when its setting is the default sentinel or unset", () => {
expect(tinyWorkerEnvOverlay({}, "default", "default")).toEqual({});
expect(tinyWorkerEnvOverlay({}, undefined, undefined)).toEqual({});
});
});