serverless/test/unit/lib/configuration/variables/eventually-report-resolution-errors.test.js
Mariusz Nowak 731b3ba1e1 feat(Variables): Remove old variables resolver
BREAKING CHANGE:
Old variables resolver is permanently removed. Any resolution error as approached with current resolver is assumed as final (there's no longer fallback to old resolver)
2022-01-27 15:21:58 +01:00

36 lines
1.4 KiB
JavaScript

'use strict';
const { expect } = require('chai');
const overrideArgv = require('process-utils/override-argv');
const ServerlessError = require('../../../../../lib/serverless-error');
const resolveCliInput = require('../../../../../lib/cli/resolve-input');
const resolveMeta = require('../../../../../lib/configuration/variables/resolve-meta');
const eventuallyReportResolutionErrors = require('../../../../../lib/configuration/variables/eventually-report-resolution-errors');
describe('test/unit/lib/configuration/variables/eventually-report-resolution-errors.test.js', () => {
beforeEach(() => {
resolveCliInput.clear();
});
it('should return "false" on no errors', () => {
const configuration = { foo: 'bar' };
const variablesMeta = resolveMeta(configuration);
expect(eventuallyReportResolutionErrors(process.cwd(), configuration, variablesMeta)).to.equal(
false
);
});
describe('On errors', () => {
it('should throw error in regular circumstances', () => {
const configuration = { foo: '${foo:raz' };
const variablesMeta = resolveMeta(configuration);
overrideArgv({ args: ['serverless', 'foo'] }, () =>
expect(() => eventuallyReportResolutionErrors(process.cwd(), configuration, variablesMeta))
.to.throw(ServerlessError)
.with.property('code', 'VARIABLES_RESOLUTION_ERROR')
);
});
});
});