mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:10:44 +00:00
test: tighten plugin contract async callbacks
This commit is contained in:
@@ -372,15 +372,13 @@ async function resolveDemoLocalApiKey(params: {
|
||||
storedKeys: string[];
|
||||
configuredApiKey: string;
|
||||
}) {
|
||||
let resolved!: Awaited<ReturnType<typeof resolveApiKeyForProvider>>;
|
||||
await withEnvAsync({ DEMO_LOCAL_API_KEY: params.envApiKey }, async () => {
|
||||
resolved = await resolveApiKeyForProvider({
|
||||
return await withEnvAsync({ DEMO_LOCAL_API_KEY: params.envApiKey }, async () => {
|
||||
return await resolveApiKeyForProvider({
|
||||
provider: "demo-local",
|
||||
store: buildDemoLocalStore(params.storedKeys),
|
||||
cfg: buildDemoLocalProviderCfg(params.configuredApiKey),
|
||||
});
|
||||
});
|
||||
return resolved;
|
||||
}
|
||||
|
||||
describe("getApiKeyForModel", () => {
|
||||
|
||||
@@ -1976,7 +1976,7 @@ describe("host-hook fixture plugin contract", () => {
|
||||
|
||||
it("does not let stale scheduler cleanup delete a newer job generation", async () => {
|
||||
let releaseCleanup: (() => void) | undefined;
|
||||
let markCleanupStarted!: () => void;
|
||||
let markCleanupStarted: (() => void) | undefined;
|
||||
const cleanupStartedPromise = new Promise<void>((resolve) => {
|
||||
markCleanupStarted = resolve;
|
||||
});
|
||||
@@ -1994,6 +1994,9 @@ describe("host-hook fixture plugin contract", () => {
|
||||
sessionKey: "agent:main:main",
|
||||
kind: "monitor",
|
||||
cleanup: async () => {
|
||||
if (!markCleanupStarted) {
|
||||
throw new Error("Expected scheduler cleanup start callback to be initialized");
|
||||
}
|
||||
markCleanupStarted();
|
||||
await new Promise<void>((resolve) => {
|
||||
releaseCleanup = resolve;
|
||||
@@ -2027,7 +2030,10 @@ describe("host-hook fixture plugin contract", () => {
|
||||
},
|
||||
});
|
||||
|
||||
releaseCleanup?.();
|
||||
if (!releaseCleanup) {
|
||||
throw new Error("Expected scheduler cleanup release callback to be initialized");
|
||||
}
|
||||
releaseCleanup();
|
||||
await expect(cleanupPromise).resolves.toMatchObject({ failures: [] });
|
||||
expect(listPluginSessionSchedulerJobs("scheduler-race")).toEqual([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user