mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 17:43:03 +03:00
cd78594590
* test: configure vitest and RTL * test: add test boilerplates * feat(ci): added test-unit frontend --------- Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
36 lines
926 B
TypeScript
36 lines
926 B
TypeScript
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const getProcessEnvManager = () => {
|
|
const originalEnvValues = { ...process.env };
|
|
|
|
const overwriteEnvValuesWith = (values: Record<string, unknown>): void => {
|
|
Object.keys(values).forEach((key) => {
|
|
process.env[key] = values[key] as string;
|
|
});
|
|
};
|
|
|
|
const clearEnvValues = (): void => {
|
|
//remove all existing env values
|
|
Object.keys(process.env).forEach((key) => {
|
|
delete process.env[key];
|
|
});
|
|
};
|
|
|
|
const resetEnvValues = (): void => {
|
|
clearEnvValues();
|
|
Object.keys(originalEnvValues).forEach((key) => {
|
|
process.env[key] = originalEnvValues[key] as string;
|
|
});
|
|
};
|
|
|
|
const getCurrentEnvValues = (): Record<string, unknown> => {
|
|
return { ...process.env };
|
|
};
|
|
|
|
return {
|
|
resetEnvValues,
|
|
overwriteEnvValuesWith,
|
|
originalEnvValues,
|
|
getCurrentEnvValues,
|
|
};
|
|
};
|