Skip to content

Commit

Permalink
Merge pull request #527 from DataDog/etienne.lefebvre/synthetics/trig…
Browse files Browse the repository at this point in the history
…ger-app-env

[Synthetics] Use environment variable value for `trigger_app` when present
  • Loading branch information
lefebvree authored May 4, 2022
2 parents c07b333 + 6b9fcb5 commit 18f4414
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/commands/synthetics/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as fs from 'fs'
import {AxiosError, AxiosRequestConfig, AxiosResponse, default as axios} from 'axios'
import glob from 'glob'

process.env.DATADOG_SYNTHETICS_CI_TRIGGER_APP = 'env_default'

import * as ciHelpers from '../../../helpers/ci'
import {Metadata} from '../../../helpers/interfaces'
import {ProxyConfiguration} from '../../../helpers/utils'
Expand Down Expand Up @@ -108,7 +110,7 @@ describe('utils', () => {
}) as any)

await utils.runTests(api, [{public_id: fakeId, executionRule: ExecutionRule.NON_BLOCKING}])
expect(headersMetadataSpy).toHaveBeenCalledWith(expect.objectContaining({'X-Trigger-App': 'npm_package'}))
expect(headersMetadataSpy).toHaveBeenCalledWith(expect.objectContaining({'X-Trigger-App': 'env_default'}))

utils.setCiTriggerApp('unit_test')
await utils.runTests(api, [{public_id: fakeId, executionRule: ExecutionRule.NON_BLOCKING}])
Expand Down
2 changes: 1 addition & 1 deletion src/commands/synthetics/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const TEMPLATE_REGEX = /{{\s*([^{}]*?)\s*}}/g
const template = (st: string, context: any): string =>
st.replace(TEMPLATE_REGEX, (match: string, p1: string) => (p1 in context ? context[p1] : match))

export let ciTriggerApp = 'npm_package'
export let ciTriggerApp = process.env.DATADOG_SYNTHETICS_CI_TRIGGER_APP || 'npm_package'

export const handleConfig = (
test: InternalTest,
Expand Down

0 comments on commit 18f4414

Please sign in to comment.