Skip to content

Commit

Permalink
test: base isExpectedServerAddress assertion on envvar rather than ke…
Browse files Browse the repository at this point in the history
…ying off targetService
  • Loading branch information
trentm committed Dec 11, 2024
1 parent 71f9b27 commit 423fb34
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/instrumentation-openai/test/fixtures.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,9 @@ function isPositiveInteger(val) {
}

function isExpectedServerAddress(val) {
if (targetService === 'openai') {
return val === 'api.openai.com';
} else if (targetService === 'azure') {
return val === new URL(process.env.AZURE_OPENAI_ENDPOINT).hostname;
} else if (targetService === 'ollama') {
return val === '127.0.0.1';
} else {
return false;
}
const baseUrl = process.env.AZURE_OPENAI_API_KEY && process.env.AZURE_OPENAI_ENDPOINT || process.env.OPENAI_BASE_URL || 'https://api.openai.com';

Check failure on line 184 in packages/instrumentation-openai/test/fixtures.test.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·process.env.AZURE_OPENAI_API_KEY·&&·process.env.AZURE_OPENAI_ENDPOINT·||·process.env.OPENAI_BASE_URL·||` with `⏎····(process.env.AZURE_OPENAI_API_KEY·&&·process.env.AZURE_OPENAI_ENDPOINT)·||⏎····process.env.OPENAI_BASE_URL·||⏎···`
const expectedHostname = new URL(baseUrl).hostname;
return val === expectedHostname;
}

function isExpectedServerPort(val) {
Expand Down

0 comments on commit 423fb34

Please sign in to comment.