-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathclearcut-logger.test.ts
More file actions
47 lines (39 loc) · 1.37 KB
/
clearcut-logger.test.ts
File metadata and controls
47 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import assert from 'node:assert';
import {describe, it, mock} from 'node:test';
import {ClearcutLogger} from '../../src/telemetry/clearcut-logger.js';
import {ClearcutSender} from '../../src/telemetry/clearcut-sender.js';
describe('ClearcutLogger', () => {
it('should log tool invocation via sender', async () => {
const sender = new ClearcutSender();
const sendSpy = mock.method(sender, 'send');
const loggerInstance = new ClearcutLogger(sender);
await loggerInstance.logToolInvocation({
toolName: 'test-tool',
success: true,
latencyMs: 100,
});
assert.strictEqual(sendSpy.mock.callCount(), 1);
const event = sendSpy.mock.calls[0].arguments[0];
assert.deepStrictEqual(event.tool_invocation, {
tool_name: 'test-tool',
success: true,
latency_ms: 100,
});
});
it('should log server start via sender', async () => {
const sender = new ClearcutSender();
const sendSpy = mock.method(sender, 'send');
const loggerInstance = new ClearcutLogger(sender);
await loggerInstance.logServerStart({headless: true});
assert.strictEqual(sendSpy.mock.callCount(), 1);
const event = sendSpy.mock.calls[0].arguments[0];
assert.deepStrictEqual(event.server_start, {
flag_usage: {headless: true},
});
});
});