mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: tighten copilot token cache assertion
This commit is contained in:
@@ -77,6 +77,8 @@ describe("resolveCopilotApiToken", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("refreshes legacy cached tokens without the vscode-chat integration identity", async () => {
|
it("refreshes legacy cached tokens without the vscode-chat integration identity", async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.setSystemTime(new Date("2026-01-02T03:04:05.000Z"));
|
||||||
const fetchImpl = vi.fn(async () => ({
|
const fetchImpl = vi.fn(async () => ({
|
||||||
ok: true,
|
ok: true,
|
||||||
json: async () => ({
|
json: async () => ({
|
||||||
@@ -86,6 +88,7 @@ describe("resolveCopilotApiToken", () => {
|
|||||||
}));
|
}));
|
||||||
const saveJsonFileImpl = vi.fn();
|
const saveJsonFileImpl = vi.fn();
|
||||||
|
|
||||||
|
try {
|
||||||
const result = await resolveCopilotApiToken({
|
const result = await resolveCopilotApiToken({
|
||||||
githubToken: "github-token",
|
githubToken: "github-token",
|
||||||
cachePath: "/tmp/github-copilot-token-test.json",
|
cachePath: "/tmp/github-copilot-token-test.json",
|
||||||
@@ -102,9 +105,12 @@ describe("resolveCopilotApiToken", () => {
|
|||||||
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
||||||
expect(saveJsonFileImpl).toHaveBeenCalledWith("/tmp/github-copilot-token-test.json", {
|
expect(saveJsonFileImpl).toHaveBeenCalledWith("/tmp/github-copilot-token-test.json", {
|
||||||
token: "fresh-copilot-token",
|
token: "fresh-copilot-token",
|
||||||
expiresAt: expect.any(Number),
|
expiresAt: 1_767_326_645_000,
|
||||||
updatedAt: expect.any(Number),
|
updatedAt: 1_767_323_045_000,
|
||||||
integrationId: COPILOT_INTEGRATION_ID,
|
integrationId: COPILOT_INTEGRATION_ID,
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
vi.useRealTimers();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user