tests(apps.service): use new helpers to isolate tests
This commit is contained in:
parent
91bb537e73
commit
b4aee1da7b
3 changed files with 360 additions and 335 deletions
|
@ -53,11 +53,11 @@ describe('Test: checkAppRequirements()', () => {
|
|||
describe('Test: getEnvMap()', () => {
|
||||
it('should return a map of env vars', async () => {
|
||||
// arrange
|
||||
const appConfig = createAppConfig();
|
||||
const app = await insertApp({}, appConfig, db);
|
||||
const appConfig = createAppConfig({ form_fields: [{ env_variable: 'TEST_FIELD', type: 'text', label: 'test', required: true }] });
|
||||
insertApp({ config: { TEST_FIELD: 'test' } }, appConfig, db);
|
||||
|
||||
// act
|
||||
const envMap = getEnvMap(app.id);
|
||||
const envMap = getEnvMap(appConfig.id);
|
||||
|
||||
// assert
|
||||
expect(envMap.get('TEST_FIELD')).toBe('test');
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -139,7 +139,7 @@ const createApp = async (props: IProps, database: TestDatabase) => {
|
|||
const insertApp = async (data: Partial<NewApp>, appInfo: AppInfo, database: TestDatabase) => {
|
||||
const values: NewApp = {
|
||||
id: appInfo.id,
|
||||
config: { TEST_FIELD: 'test' },
|
||||
config: {},
|
||||
status: 'running',
|
||||
exposed: false,
|
||||
domain: null,
|
||||
|
@ -150,7 +150,9 @@ const insertApp = async (data: Partial<NewApp>, appInfo: AppInfo, database: Test
|
|||
const mockFiles: Record<string, string | string[]> = {};
|
||||
if (data.status !== 'missing') {
|
||||
mockFiles[`/app/storage/app-data/${values.id}`] = '';
|
||||
mockFiles[`/app/storage/app-data/${values.id}/app.env`] = 'TEST=test\nAPP_PORT=3000\nTEST_FIELD=test';
|
||||
mockFiles[`/app/storage/app-data/${values.id}/app.env`] = `TEST=test\nAPP_PORT=3000\n${Object.entries(data.config || {})
|
||||
.map(([key, value]) => `${key}=${value}`)
|
||||
.join('\n')}`;
|
||||
mockFiles[`/runtipi/apps/${values.id}/config.json`] = JSON.stringify(appInfo);
|
||||
mockFiles[`/runtipi/apps/${values.id}/metadata/description.md`] = 'md desc';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue