mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const { expect } = require('chai');
|
|
|
|
const fs = require('fs').promises;
|
|
const resolve = require('../../../../../lib/configuration/variables');
|
|
|
|
describe('test/unit/lib/configuration/variables/index.test.js', () => {
|
|
let configuration;
|
|
before(async () => {
|
|
process.env.ENV_SOURCE_TEST = 'foobar';
|
|
await fs.writeFile('foo.json', JSON.stringify({ json: 'content' }));
|
|
configuration = {
|
|
env: '${env:ENV_SOURCE_TEST}',
|
|
file: '${file(foo.json)}',
|
|
opt: '${opt:option}',
|
|
self: '${self:opt}',
|
|
strToBool: "${strToBool('false')}",
|
|
};
|
|
await resolve({
|
|
serviceDir: process.cwd(),
|
|
configuration,
|
|
options: { option: 'bar' },
|
|
});
|
|
});
|
|
|
|
after(() => {
|
|
delete process.env.ENV_SOURCE_TEST;
|
|
});
|
|
|
|
it('should resolve "env" source', () => expect(configuration.env).to.equal('foobar'));
|
|
it('should resolve "file" source', () =>
|
|
expect(configuration.file).to.deep.equal({ json: 'content' }));
|
|
it('should resolve "opt" source', () => expect(configuration.opt).to.equal('bar'));
|
|
it('should resolve "self" source', () => expect(configuration.self).to.equal('bar'));
|
|
it('should resolve "strToBool" source', () => expect(configuration.strToBool).to.equal(false));
|
|
});
|