Skip to content

Commit 8c67d50

Browse files
committed
test: cover empty-value refactors
Pin the undefined values returned when profiler info or suite coverage is absent. Exercise legacy OpenAI edit logging through the public SDK path so the lazy store branch remains covered.
1 parent b46d313 commit 8c67d50

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

packages/datadog-plugin-openai/test/index.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const assert = require('node:assert/strict')
66
const Path = require('path')
77
const { inspect } = require('node:util')
88

9+
const nock = require('nock')
910
const semver = require('semver')
1011
const sinon = require('sinon')
1112

@@ -160,6 +161,30 @@ describe('Plugin', () => {
160161
sinon.assert.neverCalledWith(metricStub, 'openai.ratelimit.remaining.tokens')
161162
})
162163

164+
it('logs edit instructions', async function () {
165+
if (semver.satisfies(realVersion, '>=4.0.0')) {
166+
this.skip()
167+
}
168+
169+
const instruction = 'Fix the spelling mistakes.'
170+
const scope = nock('http://127.0.0.1:9126')
171+
.post('/vcr/openai/edits')
172+
.reply(200, {
173+
choices: [{ index: 0, text: 'What day of the week is it?' }],
174+
})
175+
176+
const checkTrace = agent.assertFirstTraceSpan({ error: 0 })
177+
await openai.createEdit({
178+
input: 'What day of the wek is it?',
179+
instruction,
180+
model: 'text-davinci-edit-001',
181+
})
182+
await checkTrace
183+
184+
scope.done()
185+
sinon.assert.calledWithMatch(externalLoggerStub, { instruction })
186+
})
187+
163188
describe('maintains context', () => {
164189
it('should maintain the context with a non-streamed call', async () => {
165190
await tracer.trace('outer', async (outerSpan) => {

packages/dd-trace/test/ci-visibility/intelligent-test-runner/get-skippable-suites.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe('get-skippable-suites', () => {
208208
assert.strictEqual(err, null)
209209
assert.deepStrictEqual(skippableSuites, ['suite1.spec.js', 'suite2.spec.js'])
210210
assert.strictEqual(correlationId, 'corr-123')
211-
assert.deepStrictEqual(coverage, {})
211+
assert.strictEqual(coverage, undefined)
212212
done()
213213
})
214214
})

packages/dd-trace/test/profiling/profilers/space.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,10 @@ describe('profilers/native/space', () => {
9999
sinon.assert.calledOnce(pprof.heap.stop)
100100
})
101101

102-
it('should provide info', () => {
102+
it('should not provide info', () => {
103103
const profiler = makeSpace(NativeSpaceProfiler)
104104

105-
const info = profiler.getInfo()
106-
assert.strictEqual(Object.keys(info).length, 0)
105+
assert.strictEqual(profiler.getInfo(), undefined)
107106
})
108107

109108
it('should collect profiles from the pprof space profiler', () => {

0 commit comments

Comments
 (0)