refactor(core): dedupe command, hook, and cron fixtures

This commit is contained in:
Peter Steinberger
2026-03-02 21:30:58 +00:00
parent 5f0cbd0edc
commit 91dd89313a
16 changed files with 325 additions and 330 deletions

View File

@@ -29,6 +29,19 @@ function createHuggingfacePrompter(params: {
return createWizardPrompter(overrides, { defaultSelect: "" });
}
type ApplyHuggingfaceParams = Parameters<typeof applyAuthChoiceHuggingface>[0];
async function runHuggingfaceApply(
params: Omit<ApplyHuggingfaceParams, "authChoice" | "setDefaultModel"> &
Partial<Pick<ApplyHuggingfaceParams, "setDefaultModel">>,
) {
return await applyAuthChoiceHuggingface({
authChoice: "huggingface-api-key",
setDefaultModel: params.setDefaultModel ?? true,
...params,
});
}
describe("applyAuthChoiceHuggingface", () => {
const lifecycle = createAuthTestLifecycle([
"OPENCLAW_STATE_DIR",
@@ -75,12 +88,10 @@ describe("applyAuthChoiceHuggingface", () => {
const prompter = createHuggingfacePrompter({ text, select });
const runtime = createExitThrowingRuntime();
const result = await applyAuthChoiceHuggingface({
authChoice: "huggingface-api-key",
const result = await runHuggingfaceApply({
config: {},
prompter,
runtime,
setDefaultModel: true,
});
expect(result).not.toBeNull();
@@ -132,12 +143,10 @@ describe("applyAuthChoiceHuggingface", () => {
const prompter = createHuggingfacePrompter({ text, select, confirm });
const runtime = createExitThrowingRuntime();
const result = await applyAuthChoiceHuggingface({
authChoice: "huggingface-api-key",
const result = await runHuggingfaceApply({
config: {},
prompter,
runtime,
setDefaultModel: true,
opts: {
tokenProvider,
token,
@@ -167,12 +176,10 @@ describe("applyAuthChoiceHuggingface", () => {
const prompter = createHuggingfacePrompter({ text, select, note });
const runtime = createExitThrowingRuntime();
const result = await applyAuthChoiceHuggingface({
authChoice: "huggingface-api-key",
const result = await runHuggingfaceApply({
config: {},
prompter,
runtime,
setDefaultModel: true,
});
expect(result).not.toBeNull();