export function getFakeCommandOutput()

in src/test-helpers/app-runner-commands.ts [56:88]


export function getFakeCommandOutput(config: ICommandConfig, input: ExpectedCommandInputs, logInstance: ICommandLog): SupportedCommandOutput {
    if (AppRunnerClientCommands.isCreateServiceCommand(input)) {
        const iteration = logInstance.create.length;
        logInstance.create.push(input);
        if (!config.createServiceCommand || config.createServiceCommand.length <= iteration) {
            throw new Error(`Unexpected CreateServiceCommand call #${iteration}: ${JSON.stringify(input, undefined, 2)}`);
        }
        return config.createServiceCommand[iteration];
    } else if (AppRunnerClientCommands.isUpdateServiceCommand(input)) {
        const iteration = logInstance.update.length;
        logInstance.update.push(input);
        if (!config.updateServiceCommand || config.updateServiceCommand.length <= iteration) {
            throw new Error(`Unexpected UpdateServiceCommand call #${iteration}: ${JSON.stringify(input, undefined, 2)}`);
        }
        return config.updateServiceCommand[iteration];
    } else if (AppRunnerClientCommands.isDescribeServiceCommand(input)) {
        const iteration = logInstance.describe.length;
        logInstance.describe.push(input);
        if (!config.describeServiceCommand || config.describeServiceCommand.length <= iteration) {
            throw new Error(`Unexpected DescribeServiceCommand call #${iteration}: ${JSON.stringify(input, undefined, 2)}`);
        }
        return config.describeServiceCommand[iteration];
    } else if (AppRunnerClientCommands.isListServicesCommand(input)) {
        const iteration = logInstance.list.length;
        logInstance.list.push(input);
        if (!config.listServicesCommand || config.listServicesCommand.length <= iteration) {
            throw new Error(`Unexpected ListServicesCommand call #${iteration}: ${JSON.stringify(input, undefined, 2)}`);
        }
        return config.listServicesCommand[iteration];
    } else {
        throw new Error(`Unexpected input shape: ${JSON.stringify(input, undefined, 2)}`);
    }
}