attempt at fixing some windows test failures

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-09-16 10:46:03 +02:00
parent 3ee520091b
commit 95126b1033
3 changed files with 47 additions and 34 deletions
@@ -15,6 +15,7 @@
*/
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import { ConfigSources } from './ConfigSources';
import { ConfigSource } from './types';
import { MutableConfigSource } from './MutableConfigSource';
@@ -41,6 +42,8 @@ function mergeSources(source: ConfigSource): ConfigSource[] {
] as ConfigSource[];
}
const root = resolvePath('/');
describe('ConfigSources', () => {
it('should parse args', () => {
expect(ConfigSources.parseArgs([])).toEqual([]);
@@ -70,7 +73,7 @@ describe('ConfigSources', () => {
mergeSources(
ConfigSources.defaultForTargets({ rootDir: '/', targets: [] }),
),
).toEqual([{ name: 'FileConfigSource', path: '/app-config.yaml' }]);
).toEqual([{ name: 'FileConfigSource', path: `${root}app-config.yaml` }]);
const fsSpy = jest.spyOn(fs, 'pathExistsSync').mockReturnValue(true);
expect(
@@ -78,8 +81,8 @@ describe('ConfigSources', () => {
ConfigSources.defaultForTargets({ rootDir: '/', targets: [] }),
),
).toEqual([
{ name: 'FileConfigSource', path: '/app-config.yaml' },
{ name: 'FileConfigSource', path: '/app-config.local.yaml' },
{ name: 'FileConfigSource', path: `${root}app-config.yaml` },
{ name: 'FileConfigSource', path: `${root}app-config.local.yaml` },
]);
fsSpy.mockRestore();
@@ -90,7 +93,7 @@ describe('ConfigSources', () => {
targets: [{ type: 'path', target: '/config.yaml' }],
}),
),
).toEqual([{ name: 'FileConfigSource', path: '/config.yaml' }]);
).toEqual([{ name: 'FileConfigSource', path: `${root}config.yaml` }]);
const subFunc = async () => undefined;
expect(
@@ -104,7 +107,7 @@ describe('ConfigSources', () => {
).toEqual([
{
name: 'FileConfigSource',
path: '/config.yaml',
path: `${root}config.yaml`,
substitutionFunc: subFunc,
},
]);
@@ -156,7 +159,7 @@ describe('ConfigSources', () => {
}),
),
).toEqual([
{ name: 'FileConfigSource', path: '/app-config.yaml' },
{ name: 'FileConfigSource', path: `${root}app-config.yaml` },
{ name: 'EnvConfigSource', env: { HOME: '/' } },
]);
@@ -190,9 +193,9 @@ describe('ConfigSources', () => {
]),
),
).toEqual([
{ name: 'FileConfigSource', path: '/a.yaml' },
{ name: 'FileConfigSource', path: '/b.yaml' },
{ name: 'FileConfigSource', path: '/c.yaml' },
{ name: 'FileConfigSource', path: `${root}a.yaml` },
{ name: 'FileConfigSource', path: `${root}b.yaml` },
{ name: 'FileConfigSource', path: `${root}c.yaml` },
]);
});