mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:44:33 +00:00
refactor(core): dedupe command, hook, and cron fixtures
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user