Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use path where needed to make unit tests on Windows pass. #188

Merged
merged 1 commit into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/packExternalModules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('packExternalModules', () => {
sandbox.restore();
});

describe('packageModules()', () => {
describe('packExternalModules()', () => {
it('should do nothing if webpackIncludeModules is not set', () => {
_.unset(serverless, 'service.custom.webpackIncludeModules');
return expect(module.packExternalModules({ stats: [] })).to.eventually.deep.equal({ stats: [] })
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('packExternalModules', () => {
'bluebird@^3.4.0'
],
{
cwd: 'outputPath/dependencies',
cwd: path.join('outputPath', 'dependencies'),
maxBuffer: 204800,
save: true
}),
Expand Down
21 changes: 13 additions & 8 deletions tests/packageModules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const BbPromise = require('bluebird');
const _ = require('lodash');
const chai = require('chai');
const path = require('path');
const sinon = require('sinon');
const mockery = require('mockery');
const Serverless = require('serverless');
Expand Down Expand Up @@ -134,10 +135,12 @@ describe('packageModules', () => {
fsMock._streamMock.on.withArgs('close').yields();
fsMock._statMock.isDirectory.returns(false);

const expectedArtifactPath = path.join('.serverless', 'test-service.zip');

return expect(module.packageModules(stats)).to.be.fulfilled
.then(() => BbPromise.all([
expect(func1).to.have.a.nested.property('package.artifact').that.equals('.serverless/test-service.zip'),
expect(func2).to.have.a.nested.property('package.artifact').that.equals('.serverless/test-service.zip'),
expect(func1).to.have.a.nested.property('package.artifact').that.equals(expectedArtifactPath),
expect(func2).to.have.a.nested.property('package.artifact').that.equals(expectedArtifactPath),
]));
});

Expand Down Expand Up @@ -205,8 +208,8 @@ describe('packageModules', () => {

return expect(module.packageModules(stats)).to.be.fulfilled
.then(() => BbPromise.all([
expect(func1).to.have.a.nested.property('package.artifact').that.equals('.serverless/func1.zip'),
expect(func2).to.have.a.nested.property('package.artifact').that.equals('.serverless/func2.zip'),
expect(func1).to.have.a.nested.property('package.artifact').that.equals(path.join('.serverless', 'func1.zip')),
expect(func2).to.have.a.nested.property('package.artifact').that.equals(path.join('.serverless', 'func2.zip')),
]));
});

Expand Down Expand Up @@ -252,20 +255,22 @@ describe('packageModules', () => {
fsMock._streamMock.on.withArgs('close').yields();
fsMock._statMock.isDirectory.returns(false);

const expectedArtifactPath = path.join('.serverless', 'test-service.zip');

return BbPromise.each([ '1.18.1', '2.17.0', '10.15.3', ], version => {
getVersionStub.returns(version);
return expect(module.packageModules(stats)).to.be.fulfilled
.then(() => BbPromise.all([
expect(func1).to.have.a.nested.property('package.artifact').that.equals('.serverless/test-service.zip'),
expect(func2).to.have.a.nested.property('package.artifact').that.equals('.serverless/test-service.zip'),
expect(func1).to.have.a.nested.property('package.artifact').that.equals(expectedArtifactPath),
expect(func2).to.have.a.nested.property('package.artifact').that.equals(expectedArtifactPath),
]));
})
.then(() => BbPromise.each([ '1.17.0', '1.16.0-alpha', '1.15.3', ], version => {
getVersionStub.returns(version);
return expect(module.packageModules(stats)).to.be.fulfilled
.then(() => BbPromise.all([
expect(func1).to.have.a.nested.property('artifact').that.equals('.serverless/test-service.zip'),
expect(func2).to.have.a.nested.property('artifact').that.equals('.serverless/test-service.zip'),
expect(func1).to.have.a.nested.property('artifact').that.equals(expectedArtifactPath),
expect(func2).to.have.a.nested.property('artifact').that.equals(expectedArtifactPath),
]));
}));
});
Expand Down
13 changes: 7 additions & 6 deletions tests/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const _ = require('lodash');
const chai = require('chai');
const sinon = require('sinon');
const mockery = require('mockery');
const path = require('path');
const Serverless = require('serverless');
const makeFsExtraMock = require('./fs-extra.mock');

Expand Down Expand Up @@ -104,7 +105,7 @@ describe('validate', () => {
return module
.validate()
.then(() => expect(module.webpackConfig.output).to.eql({
path: `${testServicePath}/${testOptionsOut}/service`,
path: path.join(testServicePath, testOptionsOut, 'service'),
filename: 'filename',
}));
});
Expand Down Expand Up @@ -135,7 +136,7 @@ describe('validate', () => {
.validate()
.then(() => expect(module.webpackConfig.output).to.eql({
libraryTarget: 'commonjs',
path: `${testServicePath}/.webpack/service`,
path: path.join(testServicePath, '.webpack', 'service'),
filename: '[name].js',
}));
});
Expand All @@ -152,7 +153,7 @@ describe('validate', () => {
.validate()
.then(() => expect(module.webpackConfig.output).to.eql({
libraryTarget: 'commonjs',
path: `${testServicePath}/.webpack/service`,
path: path.join(testServicePath, '.webpack', 'service'),
filename: '[name].js',
}));
});
Expand All @@ -166,7 +167,7 @@ describe('validate', () => {
.validate()
.then(() => expect(module.webpackConfig.output).to.eql({
libraryTarget: 'commonjs',
path: `${testServicePath}/.webpack/service`,
path: path.join(testServicePath, '.webpack', 'service'),
filename: '[name].js',
}));
});
Expand All @@ -176,7 +177,7 @@ describe('validate', () => {
it('should load a webpack config from file if `custom.webpack` is a string', () => {
const testConfig = 'testconfig';
const testServicePath = 'testpath';
const requiredPath = `${testServicePath}/${testConfig}`;
const requiredPath = path.join(testServicePath, testConfig);
module.serverless.config.servicePath = testServicePath;
module.serverless.service.custom.webpack = testConfig;
serverless.utils.fileExistsSync = sinon.stub().returns(true);
Expand Down Expand Up @@ -206,7 +207,7 @@ describe('validate', () => {
it('should load a default file if no custom config is provided', () => {
const testConfig = 'webpack.config.js';
const testServicePath = 'testpath';
const requiredPath = `${testServicePath}/${testConfig}`;
const requiredPath = path.join(testServicePath, testConfig);
module.serverless.config.servicePath = testServicePath;
serverless.utils.fileExistsSync = sinon.stub().returns(true);
const loadedConfig = {
Expand Down