export async function hydrateTestCaseSeed()

in apps/firelens-stability/lib/helpers/start-execution-stages.ts [168:213]


export async function hydrateTestCaseSeed(testCaseSeed: ITestCaseSeed):
                                       Promise<ITestCase> {

    /* Cascade config by order of precidence, highest last */
    const baseConfig = {
        managed: testCaseSeed.managedVariables,
        config: Constants.defaults.config as ICaseConfig, /* Config could also come from a file */
        definitions: {},
    };

    const layer2Config = cascadeConfigurationStringAsExtension(testCaseSeed.collectionConfigSeed, baseConfig);
    const layer2ExecutionOverride = cascadeConfigurationStringAsExtension(testCaseSeed.executionConfigSeed, layer2Config);
    const layer3Config = cascadeConfigurationStringAsExtension(testCaseSeed.suiteConfigSeed, layer2ExecutionOverride);
    const layer3ExecutionOverride = cascadeConfigurationStringAsExtension(testCaseSeed.executionConfigSeed, layer3Config);
    const layer4Config = cascadeConfigurationStringAsExtension(testCaseSeed.caseConfigSeed, layer3ExecutionOverride);
    const layer4ExecutionOverride = cascadeConfigurationStringAsExtension(testCaseSeed.executionConfigSeed, layer4Config);
    const layer5Config = cascadeConfigurationStringAsExtension(testCaseSeed.caseSeed, layer4ExecutionOverride);

    /* Apply execution config before and after template to ensure overrides are set - allow set template */
    const layer5ExecutionOverride = cascadeConfigurationStringAsExtension(testCaseSeed.executionConfigSeed, layer5Config);

    /* Get template */
    const templateName = layer5ExecutionOverride.config.template;
    if (!templateName) {
        validateTestConfig(layer5ExecutionOverride);
    }
    const templateConfigPath = Path.join(Constants.paths.templates, templateName, Constants.fileNames.templateDefaultConfig);
    const templateConfig = await getStringFromFile(templateConfigPath);
    const layer7Config = cascadeConfigurationStringAsDefault(templateConfig, layer5ExecutionOverride);

    /* Final layer of configuration from execution seed. These function as overrides. */
    const config = cascadeConfigurationStringAsExtension(testCaseSeed.executionConfigSeed, layer7Config);

    validateTestConfig(config);
    
    const archiveLocalPath = Path.join(Constants.paths.auto, Constants.folderNames.archives, config.managed.s3ResourcesPath);
    const archiveArn = config.managed.s3ResourcesArn;

    return {
        ...config,
        local: {
            archiveLocalPath,
            archiveArn
        }
    };
}