Skip to content

Commit

Permalink
test: Upgrade to new runServerless version
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Apr 9, 2021
1 parent 6dd3996 commit 2d1b56b
Show file tree
Hide file tree
Showing 237 changed files with 633 additions and 465 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.nyc_output
/coverage
/test/fixtures/configSyntaxError/serverless.yml
/test/fixtures/cli/configSyntaxError/serverless.yml
/test/unit/lib/configuration/variables/sources/fixture/invalid.json
/test/unit/lib/configuration/variables/sources/fixture/invalid.yml
!/test/fixtures/programmatic/locallyInstalledServerless/node_modules/**
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"devDependencies": {
"@commitlint/cli": "^12.1.1",
"@serverless/eslint-config": "^3.0.0",
"@serverless/test": "^7.11.0",
"@serverless/test": "^8.0.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"cos-nodejs-sdk-v5": "^2.9.13",
Expand Down Expand Up @@ -121,7 +121,8 @@
"eslintIgnore": [
"!/.github",
"/lib/plugins/create/templates/**",
"/lib/plugins/aws/customResources/node_modules/**"
"/lib/plugins/aws/customResources/node_modules/**",
"!/test/fixtures/programmatic/locallyInstalledServerless/node_modules/**"
],
"mocha": {
"require": [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions test/fixtures/programmatic/blank/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions test/fixtures/programmatic/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('@serverless/test/setup-fixtures-engine')(__dirname);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = (originalFixturePath) => {
fixtureModulePath,
String(content).replace(
'$SERVERLESS_PATH',
JSON.stringify(path.resolve(originalFixturePath, '../../../'))
JSON.stringify(path.resolve(originalFixturePath, '../../../../'))
)
);
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/integration/apiGateway.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const awsRequest = require('@serverless/test/aws-request');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { confirmCloudWatchLogs } = require('../utils/misc');
const { deployService, removeService, fetch } = require('../utils/integration');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/apiGatewayExternal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const awsRequest = require('@serverless/test/aws-request');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { deployService, removeService, fetch } = require('../utils/integration');
const { createRestApi, deleteRestApi, getResources } = require('../utils/apiGateway');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cognitoUserPool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const BbPromise = require('bluebird');
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const hasFailed = require('@serverless/test/has-failed');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const {
createUserPool,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/eventBridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { confirmCloudWatchLogs } = require('../utils/misc');
const {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/functionDestinations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const awsRequest = require('@serverless/test/aws-request');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');
const { confirmCloudWatchLogs } = require('../utils/misc');

const { deployService, removeService } = require('../utils/integration');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/httpApi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const awsRequest = require('@serverless/test/aws-request');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');
const { confirmCloudWatchLogs } = require('../utils/misc');

const { deployService, removeService, fetch } = require('../utils/integration');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/infra-dependent/fileSystemConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../../fixtures');
const fixtures = require('../../fixtures/programmatic');

const awsRequest = require('@serverless/test/aws-request');
const crypto = require('crypto');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/infra-dependent/msk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../../fixtures');
const fixtures = require('../../fixtures/programmatic');
const { confirmCloudWatchLogs } = require('../../utils/misc');
const {
isDependencyStackAvailable,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/iot.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { expect } = require('chai');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { publishIotData } = require('../utils/iot');
const { confirmCloudWatchLogs } = require('../utils/misc');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/iotFleetProvisioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const awsRequest = require('@serverless/test/aws-request');
const { expect } = require('chai');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');
const { deployService, removeService } = require('../utils/integration');
const { resolveIotEndpoint } = require('../utils/iot');

Expand Down
2 changes: 1 addition & 1 deletion test/integration/provisionedConcurrency.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { createKinesisStream, deleteKinesisStream, putKinesisRecord } = require('../utils/kinesis');
const { createSqsQueue, deleteSqsQueue, sendSqsMessage } = require('../utils/sqs');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/s3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const BbPromise = require('bluebird');
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { createBucket, createAndRemoveInBucket, deleteBucket } = require('../utils/s3');
const { deployService, removeService } = require('../utils/integration');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/schedule.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { expect } = require('chai');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { deployService, removeService } = require('../utils/integration');
const { confirmCloudWatchLogs } = require('../utils/misc');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/sns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const BbPromise = require('bluebird');
const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { confirmCloudWatchLogs } = require('../utils/misc');
const { createSnsTopic, removeSnsTopic, publishSnsMessage } = require('../utils/sns');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/sqs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { expect } = require('chai');
const hasFailed = require('@serverless/test/has-failed');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { createSqsQueue, deleteSqsQueue, sendSqsMessage } = require('../utils/sqs');
const { confirmCloudWatchLogs } = require('../utils/misc');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { expect } = require('chai');
const log = require('log').get('serverless:test');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { createKinesisStream, deleteKinesisStream, putKinesisRecord } = require('../utils/kinesis');
const { putDynamoDbItem } = require('../utils/dynamodb');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { expect } = require('chai');
const awsRequest = require('@serverless/test/aws-request');
const log = require('log').get('serverless:test');
const wait = require('timers-ext/promise/sleep');
const fixtures = require('../fixtures');
const fixtures = require('../fixtures/programmatic');

const { confirmCloudWatchLogs } = require('../utils/misc');
const { deployService, removeService } = require('../utils/integration');
Expand Down
17 changes: 9 additions & 8 deletions test/unit/lib/Serverless.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CLI = require('../../../lib/classes/CLI');
const ServerlessError = require('../../../lib/serverless-error');
const conditionallyLoadDotenv = require('../../../lib/cli/conditionally-load-dotenv');
const runServerless = require('../../utils/run-serverless');
const fixtures = require('../../fixtures');
const fixtures = require('../../fixtures/programmatic');
const fs = require('fs');

describe('Serverless', () => {
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('Serverless [new tests]', () => {
it('Should fallback to local version when it is found and "enableLocalInstallationFallback" is not set', () =>
runServerless({
fixture: 'locallyInstalledServerless',
cliArgs: ['-v'],
command: 'print',
modulesCacheStub: {},
}).then(({ serverless }) => {
expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]);
Expand All @@ -242,7 +242,7 @@ describe('Serverless [new tests]', () => {
runServerless({
fixture: 'locallyInstalledServerless',
configExt: { enableLocalInstallationFallback: false },
cliArgs: ['-v'],
command: 'print',
modulesCacheStub: {},
}).then(({ serverless }) => {
serverlessWithDisabledLocalInstallationFallback = serverless;
Expand All @@ -261,7 +261,7 @@ describe('Serverless [new tests]', () => {
runServerless({
fixture: 'locallyInstalledServerless',
configExt: { enableLocalInstallationFallback: true },
cliArgs: ['-v'],
command: 'print',
modulesCacheStub: {},
}).then(({ serverless }) => {
expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([
Expand All @@ -279,7 +279,7 @@ describe('Serverless [new tests]', () => {
runServerless({
serverlessDir: path.resolve(servicePath, 'node_modules/serverless'),
cwd: servicePath,
cliArgs: ['-v'],
command: 'print',
}).then(({ serverless }) => {
expect(Array.from(serverless.triggeredDeprecations)).to.not.include(
'DISABLE_LOCAL_INSTALLATION_FALLBACK_SETTING'
Expand All @@ -294,7 +294,7 @@ describe('Serverless [new tests]', () => {

describe('When local version not available', () => {
it('Should run without notice', () =>
runServerless({ fixture: 'aws', cliArgs: ['-v'], modulesCacheStub: {} }).then(
runServerless({ fixture: 'aws', command: 'print', modulesCacheStub: {} }).then(
({ serverless }) => {
expect(Array.from(serverless.triggeredDeprecations)).to.deep.equal([]);
expect(serverless._isInvokedByGlobalInstallation).to.be.false;
Expand Down Expand Up @@ -328,7 +328,8 @@ describe('Serverless [new tests]', () => {
it('Should load environment variables from default .env file if no matching stage', async () => {
const result = await runServerless({
cwd: servicePath,
cliArgs: ['package'],
command: 'package',
shouldUseLegacyVariablesResolver: true,
});

expect(result.serverless.service.custom.fromDefaultEnv).to.equal('valuefromdefault');
Expand All @@ -342,7 +343,7 @@ describe('Serverless [new tests]', () => {
before(async () => {
({ serverless } = await runServerless({
fixture: 'aws',
cliArgs: ['package'],
command: 'package',
}));
});

Expand Down
Loading

0 comments on commit 2d1b56b

Please sign in to comment.