2021-05-03 13:14:30 +02:00
|
|
|
import { getDefaultConfig, overrideWithEnv } from '../src/config/config'
|
2020-12-08 11:42:51 +01:00
|
|
|
|
2021-02-22 20:02:02 +01:00
|
|
|
test('overrideWithEnv 1', () => {
|
2020-12-08 11:42:51 +01:00
|
|
|
const defaultConfig = getDefaultConfig()
|
|
|
|
const env = {
|
2021-05-27 13:59:31 +02:00
|
|
|
KAFKA_ENABLED: 'false',
|
|
|
|
TASK_TIMEOUT: '3008',
|
|
|
|
CLICKHOUSE_HOST: '0.0.0.0',
|
2020-12-08 11:42:51 +01:00
|
|
|
BASE_DIR: undefined,
|
|
|
|
}
|
|
|
|
const config = overrideWithEnv(getDefaultConfig(), env)
|
|
|
|
|
2021-05-27 13:59:31 +02:00
|
|
|
expect(config.KAFKA_ENABLED).toEqual(false)
|
|
|
|
expect(config.TASK_TIMEOUT).toEqual(3008)
|
|
|
|
expect(config.CLICKHOUSE_HOST).toEqual('0.0.0.0')
|
2020-12-08 11:42:51 +01:00
|
|
|
expect(config.BASE_DIR).toEqual(defaultConfig.BASE_DIR)
|
|
|
|
})
|
|
|
|
|
2021-02-22 20:02:02 +01:00
|
|
|
test('overrideWithEnv 2', () => {
|
2020-12-08 11:42:51 +01:00
|
|
|
const defaultConfig = getDefaultConfig()
|
|
|
|
const env = {
|
2021-05-27 13:59:31 +02:00
|
|
|
KAFKA_ENABLED: '1',
|
|
|
|
TASK_TIMEOUT: '3008.12',
|
2020-12-08 11:42:51 +01:00
|
|
|
}
|
|
|
|
const config = overrideWithEnv(getDefaultConfig(), env)
|
|
|
|
|
2021-05-27 13:59:31 +02:00
|
|
|
expect(config.KAFKA_ENABLED).toEqual(true)
|
|
|
|
expect(config.TASK_TIMEOUT).toEqual(3008.12)
|
2020-12-08 11:42:51 +01:00
|
|
|
})
|