Skip to content

Commit 4e1844c

Browse files
committed
genai.test.js tweak
1 parent c2217be commit 4e1844c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ test('@google/genai unit.tests', async (t) => {
3333

3434
function getMockModule() {
3535
function GoogleGenAi() {}
36-
GoogleGenAi.HttpResponse = function () {}
37-
GoogleGenAi.HttpResponse.prototype.json = async function () {}
3836
GoogleGenAi.Models = function () {}
3937
GoogleGenAi.Models.prototype.generateContentInternal = async function () {}
4038
GoogleGenAi.Models.prototype.generateContentStreamInternal = async function () {}
@@ -48,7 +46,11 @@ test('@google/genai unit.tests', async (t) => {
4846
initialize(agent, MockGoogleGenAi, '@google/genai', shim)
4947
assert.equal(shim.logger.debug.callCount, 0, 'should not log debug messages')
5048
const isWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.generateContentInternal)
49+
const isStreamWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.generateContentStreamInternal)
50+
const isEmbedWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.embedContent)
5151
assert.equal(isWrapped, true, 'should wrap models generateContentInternal')
52+
assert.equal(isStreamWrapped, true, 'should wrap models generateContentStreamInternal')
53+
assert.equal(isEmbedWrapped, true, 'should wrap models embedContent')
5254
end()
5355
})
5456

@@ -83,7 +85,11 @@ test('@google/genai unit.tests', async (t) => {
8385
assert.equal(shim.logger.debug.callCount, 1, 'should log 1 debug message')
8486
assert.equal(shim.logger.debug.args[0][0], 'config.ai_monitoring.enabled is set to false.')
8587
const isWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.generateContentInternal)
86-
assert.equal(isWrapped, false, 'should not wrap models generate content internal')
88+
const isStreamWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.generateContentStreamInternal)
89+
const isEmbedWrapped = shim.isWrapped(MockGoogleGenAi.Models.prototype.embedContent)
90+
assert.equal(isWrapped, false, 'should not wrap models generateContentInternal')
91+
assert.equal(isStreamWrapped, false, 'should not wrap models generateContentStreamInternal')
92+
assert.equal(isEmbedWrapped, false, 'should not wrap models embedContent')
8793
end()
8894
}
8995
)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ function getExpectedResult(tx, event, type, completionId) {
5050
ingest_source: 'Node'
5151
}
5252
const resKeys = {
53-
duration: child.getDurationInMillis(),
54-
// TODO: response.headers?
53+
duration: child.getDurationInMillis()
5554
}
5655

5756
switch (type) {

0 commit comments

Comments
 (0)