Skip to content

Commit d711cb1

Browse files
committed
cleanup unit tests
1 parent 89512c8 commit d711cb1

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

test/unit/instrumentation/@google/genai.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
'use strict'
77
const test = require('node:test')
88
const assert = require('node:assert')
9-
const helper = require('../../../lib/agent_helper')
10-
const GenericShim = require('../../../../lib/shim/shim')
9+
const helper = require('#testlib/agent_helper.js')
10+
const GenericShim = require('#agentlib/shim/shim.js')
1111
const sinon = require('sinon')
1212

1313
test('@google/genai unit tests', async (t) => {

test/unit/llm-events/google-genai/chat-completion-message.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
const test = require('node:test')
99
const assert = require('node:assert')
10-
const LlmChatCompletionMessage = require('../../../../lib/llm-events/google-genai/chat-completion-message')
11-
const helper = require('../../../lib/agent_helper')
10+
const LlmChatCompletionMessage = require('#agentlib/llm-events/google-genai/chat-completion-message.js')
11+
const helper = require('#testlib/agent_helper.js')
1212
const { req, res, getExpectedResult } = require('./common')
1313

1414
test.beforeEach((ctx) => {
@@ -200,7 +200,7 @@ test('should not set token_count if not set in usage nor a callback registered r
200200
const { agent } = t.nr
201201
const api = helper.getAgentApi()
202202
function cb() {
203-
// empty cb
203+
// no-op so we don't return a token count
204204
}
205205
api.setLlmTokenCountCallback(cb)
206206
helper.runInTransaction(agent, (tx) => {

test/unit/llm-events/google-genai/chat-completion-summary.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
const test = require('node:test')
99
const assert = require('node:assert')
10-
const LlmChatCompletionSummary = require('../../../../lib/llm-events/google-genai/chat-completion-summary')
11-
const helper = require('../../../lib/agent_helper')
10+
const LlmChatCompletionSummary = require('#agentlib/llm-events/google-genai/chat-completion-summary.js')
11+
const helper = require('#testlib/agent_helper.js')
1212
const { req, res, getExpectedResult } = require('./common')
1313

1414
test.beforeEach((ctx) => {

test/unit/llm-events/google-genai/embedding.test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
const test = require('node:test')
99
const assert = require('node:assert')
10-
const LlmEmbedding = require('../../../../lib/llm-events/google-genai/embedding')
11-
const helper = require('../../../lib/agent_helper')
10+
const LlmEmbedding = require('#agentlib/llm-events/google-genai/embedding.js')
11+
const helper = require('#testlib/agent_helper.js')
1212
const { res, getExpectedResult } = require('./common')
1313

1414
test.beforeEach((ctx) => {
@@ -45,7 +45,8 @@ test('should properly create a LlmEmbedding event', (t, end) => {
4545
})
4646
})
4747
})
48-
;[
48+
49+
const serializeTestCases = [
4950
{ type: 'string', value: 'test contents', expected: 'test contents' },
5051
{
5152
type: 'array of strings',
@@ -62,20 +63,21 @@ test('should properly create a LlmEmbedding event', (t, end) => {
6263
],
6364
expected: '1,2,3,4,5,6'
6465
}
65-
].forEach(({ type, value, expected }) => {
66-
test(`should properly serialize contents when it is a ${type}`, (t, end) => {
66+
]
67+
for (const testCase of serializeTestCases) {
68+
test(`should properly serialize contents when it is a ${testCase.type}`, (t, end) => {
6769
const { agent } = t.nr
6870
const embeddingEvent = new LlmEmbedding({
6971
agent,
7072
segment: null,
7173
transaction: null,
72-
request: { contents: value },
74+
request: { contents: testCase.value },
7375
response: {}
7476
})
75-
assert.equal(embeddingEvent.input, expected)
77+
assert.equal(embeddingEvent.input, testCase.expected)
7678
end()
7779
})
78-
})
80+
}
7981

8082
test('should set error to true', (t, end) => {
8183
const { agent } = t.nr

0 commit comments

Comments
 (0)