Repository navigation
Expand file tree
/
Copy pathsettings.test.ts
More file actions
68 lines (58 loc) · 2.53 KB
/
Copy pathsettings.test.ts
File metadata and controls
68 lines (58 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { test, describe, expect } from 'vitest'
import { createSettings } from './settings.js'
describe('settings', () => {
test('should parse WORKFLOW_RUN_ID correctly', async () => {
process.env.WORKFLOW_RUN_ID = '123'
const settings = createSettings(process.env)
expect(settings.workflowRunId).toBe(123)
})
test('should set workflowRunId to undefined when WORKFLOW_RUN_ID is not set', async () => {
delete process.env.WORKFLOW_RUN_ID
const settings = createSettings(process.env)
expect(settings.workflowRunId).toBeUndefined()
})
test('should set owner and repository from environment variables', async () => {
process.env.OWNER = 'owner-name'
process.env.REPOSITORY = 'repo-name'
const settings = createSettings(process.env)
expect(settings.owner).toBe('owner-name')
expect(settings.repository).toBe('repo-name')
})
test('should set FeatureFlagTrace to false when FEATURE_TRACE is "false"', async () => {
process.env.FEATURE_TRACE = 'false'
const settings = createSettings(process.env)
expect(settings.FeatureFlagTrace).toBe(false)
})
test('should set FeatureFlagTrace to true by default when FEATURE_TRACE is not set', async () => {
delete process.env.FEATURE_TRACE
const settings = createSettings(process.env)
expect(settings.FeatureFlagTrace).toBe(true)
})
test('should set FeatureFlagMetrics to true when FEATURE_METRICS is "false"', async () => {
process.env.FEATURE_METRICS = 'false'
const settings = createSettings(process.env)
expect(settings.FeatureFlagMetrics).toBe(false)
})
test('should set FeatureFlagMetrics to true by default when FEATURE_METRICS is not set', async () => {
delete process.env.FEATURE_METRICS
const settings = createSettings(process.env)
expect(settings.FeatureFlagMetrics).toBe(true)
})
test('should set logeLevel to "debug" when RUNNER_DEBUG is "1"', async () => {
process.env.RUNNER_DEBUG = '1'
const settings = createSettings(process.env)
expect(settings.logeLevel).toBe('debug')
})
test('should set logeLevel to OTEL_LOG_LEVEL when set', async () => {
process.env.RUNNER_DEBUG = '0'
process.env.OTEL_LOG_LEVEL = 'warn'
const settings = createSettings(process.env)
expect(settings.logeLevel).toBe('warn')
})
test('should set logeLevel to "info" by default when no related env variables are set', async () => {
delete process.env.RUNNER_DEBUG
delete process.env.OTEL_LOG_LEVEL
const settings = createSettings(process.env)
expect(settings.logeLevel).toBe('info')
})
})