Skip to content

Commit 58692b9

Browse files
committed
test: tighten secrets snapshot assertions
1 parent e3b684d commit 58692b9

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

src/secrets/runtime-core-snapshots.test.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,21 @@ describe("secrets runtime snapshot core lanes", () => {
226226
}),
227227
});
228228

229-
expect(snapshot.warnings.map((warning) => warning.path)).toEqual(
230-
expect.arrayContaining([
231-
"/tmp/openclaw-agent-main.auth-profiles.openai:default.key",
232-
"/tmp/openclaw-agent-main.auth-profiles.github-copilot:default.token",
233-
]),
229+
const warningPaths = snapshot.warnings.map((warning) => warning.path);
230+
expect(warningPaths).toContain("/tmp/openclaw-agent-main.auth-profiles.openai:default.key");
231+
expect(warningPaths).toContain(
232+
"/tmp/openclaw-agent-main.auth-profiles.github-copilot:default.token",
234233
);
235-
expect(snapshot.authStores[0]?.store.profiles["openai:default"]).toMatchObject({
236-
type: "api_key",
237-
key: "sk-env-openai",
238-
});
239-
expect(snapshot.authStores[0]?.store.profiles["github-copilot:default"]).toMatchObject({
240-
type: "token",
241-
token: "ghp-env-token",
242-
});
234+
const openAiProfile = snapshot.authStores[0]?.store.profiles["openai:default"] as
235+
| Record<string, unknown>
236+
| undefined;
237+
expect(openAiProfile?.type).toBe("api_key");
238+
expect(openAiProfile?.key).toBe("sk-env-openai");
239+
const copilotProfile = snapshot.authStores[0]?.store.profiles["github-copilot:default"] as
240+
| Record<string, unknown>
241+
| undefined;
242+
expect(copilotProfile?.type).toBe("token");
243+
expect(copilotProfile?.token).toBe("ghp-env-token");
243244
});
244245

245246
it("resolves inline placeholder auth profiles to env refs", async () => {
@@ -260,13 +261,11 @@ describe("secrets runtime snapshot core lanes", () => {
260261
}),
261262
});
262263

263-
expect(snapshot.authStores[0]?.store.profiles["openai:inline"]).toMatchObject({
264-
type: "api_key",
265-
key: "sk-env-openai",
266-
});
267264
const inlineProfile = snapshot.authStores[0]?.store.profiles["openai:inline"] as
268265
| Record<string, unknown>
269266
| undefined;
267+
expect(inlineProfile?.type).toBe("api_key");
268+
expect(inlineProfile?.key).toBe("sk-env-openai");
270269
expect(inlineProfile?.keyRef).toEqual({
271270
source: "env",
272271
provider: "default",
@@ -285,11 +284,10 @@ describe("secrets runtime snapshot core lanes", () => {
285284
const prepared = await prepareOpenAiRuntimeSnapshot();
286285
activateSecretsRuntimeSnapshot(prepared);
287286

288-
expect(
289-
ensureAuthProfileStore("/tmp/openclaw-agent-main").profiles["openai:default"],
290-
).toMatchObject({
291-
type: "api_key",
292-
key: "sk-runtime",
293-
});
287+
const runtimeProfile = ensureAuthProfileStore("/tmp/openclaw-agent-main").profiles[
288+
"openai:default"
289+
] as Record<string, unknown> | undefined;
290+
expect(runtimeProfile?.type).toBe("api_key");
291+
expect(runtimeProfile?.key).toBe("sk-runtime");
294292
});
295293
});

0 commit comments

Comments
 (0)