Skip to content

Commit

Permalink
fix: update tests to catch llm fails
Browse files Browse the repository at this point in the history
  • Loading branch information
CahidArda committed Nov 6, 2024
1 parent 8dedafe commit 6bc2413
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/client/api/llm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("llm", () => {
"upstash-forward-authorization": null,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -77,6 +78,7 @@ describe("llm", () => {
"upstash-forward-helicone-auth": `Bearer ${analyticsToken}`,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -110,6 +112,7 @@ describe("llm", () => {
"upstash-forward-authorization": `Bearer ${llmToken}`,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -146,6 +149,7 @@ describe("llm", () => {
"upstash-forward-helicone-target-url": "https://api.openai.com",
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -179,6 +183,7 @@ describe("llm", () => {
"upstash-forward-x-api-key": llmToken,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -215,6 +220,7 @@ describe("llm", () => {
"upstash-forward-helicone-target-url": "https://api.anthropic.com",
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -248,6 +254,7 @@ describe("llm", () => {
"upstash-forward-authorization": `Bearer ${llmToken}`,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down Expand Up @@ -284,6 +291,7 @@ describe("llm", () => {
"upstash-forward-helicone-target-url": customBaseUrl,
"upstash-callback": callback,
"upstash-method": "POST",
"content-type": "application/json",
},
},
});
Expand Down
16 changes: 16 additions & 0 deletions src/client/llm/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ describe("Test QStash chat", () => {
callback: "https://example.com",
});
expect(result.messageId).toBeTruthy();

// sleep before checking the message
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
await new Promise((r) => setTimeout(r, 3000));

const { events } = await client.events({ filter: { messageId: result.messageId } });
const deliveredEvent = events.find((event) => event.state === "DELIVERED");
expect(deliveredEvent).not.toBeUndefined();
});

test("should batch with llm api", async () => {
Expand Down Expand Up @@ -298,6 +306,14 @@ describe("Test QStash chat with third party LLMs", () => {
callback: "https://oz.requestcatcher.com/",
});
expect(result.messageId).toBeTruthy();

// sleep before checking the message
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
await new Promise((r) => setTimeout(r, 3000));

const { events } = await client.events({ filter: { messageId: result.messageId } });
const deliveredEvent = events.find((event) => event.state === "DELIVERED");
expect(deliveredEvent).not.toBeUndefined();
});

test("should publish with llm api", () => {
Expand Down

0 comments on commit 6bc2413

Please sign in to comment.