MCPcopy Index your code
hub / github.com/coder/coder / generateMockLogs

Function generateMockLogs

site/src/modules/resources/useAgentLogs.test.ts:17–34  ·  view source on GitHub ↗
(
	logCount: number,
	baseDate = new Date("April 1, 1970"),
)

Source from the content-addressed store, hash-verified

15const millisecondsInOneMinute = 60_000;
16
17function generateMockLogs(
18 logCount: number,
19 baseDate = new Date("April 1, 1970"),
20): readonly WorkspaceAgentLog[] {
21 return Array.from({ length: logCount }, (_, i) => {
22 // Make sure that the logs generated each have unique timestamps, so
23 // that we can test whether the hook is sorting them properly as it's
24 // receiving them over time
25 const logDate = new Date(baseDate.getTime() + i * millisecondsInOneMinute);
26 return {
27 id: i,
28 created_at: logDate.toISOString(),
29 level: "info",
30 output: `Log ${i}`,
31 source_id: "",
32 };
33 });
34}
35
36// A mutable object holding the most recent mock WebSocket server that was
37// created when initializing a mock WebSocket. Inner value will be undefined if

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected