mirror of
https://github.com/actions/github-script.git
synced 2026-02-07 19:47:26 +00:00
Remove orchestration-id test file
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
This commit is contained in:
parent
f80dad6b51
commit
728b23b52d
1 changed files with 0 additions and 83 deletions
|
|
@ -1,83 +0,0 @@
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
describe('getUserAgentWithOrchestrationId', () => {
|
|
||||||
let originalEnv: NodeJS.ProcessEnv
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
originalEnv = {...process.env}
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
process.env = originalEnv
|
|
||||||
})
|
|
||||||
|
|
||||||
// Since getUserAgentWithOrchestrationId is not exported, we'll test it indirectly
|
|
||||||
// by mocking the getInput and testing the behavior through the main function integration
|
|
||||||
// For now, we'll create simple unit tests that verify the logic
|
|
||||||
|
|
||||||
test('appends orchestration ID when ACTIONS_ORCHESTRATION_ID is set', () => {
|
|
||||||
const baseUserAgent = 'actions/github-script'
|
|
||||||
const orchestrationId = 'test-orchestration-123'
|
|
||||||
process.env['ACTIONS_ORCHESTRATION_ID'] = orchestrationId
|
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
|
||||||
|
|
||||||
expect(result).toBe(
|
|
||||||
'actions/github-script orchestration-id/test-orchestration-123'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('sanitizes orchestration ID by removing special characters', () => {
|
|
||||||
const baseUserAgent = 'actions/github-script'
|
|
||||||
const orchestrationId = 'test@orchestration#123!abc$xyz'
|
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
|
||||||
|
|
||||||
expect(result).toBe(
|
|
||||||
'actions/github-script orchestration-id/testorchestration123abcxyz'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('preserves dots, hyphens, and underscores in orchestration ID', () => {
|
|
||||||
const baseUserAgent = 'actions/github-script'
|
|
||||||
const orchestrationId = 'test.orchestration-123_abc'
|
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
|
||||||
const result = `${baseUserAgent} orchestration-id/${sanitized}`
|
|
||||||
|
|
||||||
expect(result).toBe(
|
|
||||||
'actions/github-script orchestration-id/test.orchestration-123_abc'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('does not append orchestration ID when ACTIONS_ORCHESTRATION_ID is not set', () => {
|
|
||||||
const baseUserAgent = 'actions/github-script'
|
|
||||||
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
|
||||||
const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID']
|
|
||||||
const result = orchestrationId
|
|
||||||
? `${baseUserAgent} orchestration-id/${orchestrationId}`
|
|
||||||
: baseUserAgent
|
|
||||||
|
|
||||||
expect(result).toBe('actions/github-script')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('does not append orchestration ID when it becomes empty after sanitization', () => {
|
|
||||||
const baseUserAgent = 'actions/github-script'
|
|
||||||
const orchestrationId = '@#$%^&*()'
|
|
||||||
|
|
||||||
// Simulate the logic from getUserAgentWithOrchestrationId
|
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '')
|
|
||||||
const result = sanitized
|
|
||||||
? `${baseUserAgent} orchestration-id/${sanitized}`
|
|
||||||
: baseUserAgent
|
|
||||||
|
|
||||||
expect(result).toBe('actions/github-script')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Loading…
Reference in a new issue