diff --git a/.prettierignore b/.prettierignore index f3f6f365ff6..222fbdbebe5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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/** diff --git a/package.json b/package.json index 404d8345a06..dec2f3980ef 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": [ diff --git a/test/fixtures/configSyntaxError/serverless.yml b/test/fixtures/cli/configSyntaxError/serverless.yml similarity index 100% rename from test/fixtures/configSyntaxError/serverless.yml rename to test/fixtures/cli/configSyntaxError/serverless.yml diff --git a/test/fixtures/configTypeJs/serverless.js b/test/fixtures/cli/configTypeJs/serverless.js similarity index 100% rename from test/fixtures/configTypeJs/serverless.js rename to test/fixtures/cli/configTypeJs/serverless.js diff --git a/test/fixtures/configTypeJsDeferred/serverless.js b/test/fixtures/cli/configTypeJsDeferred/serverless.js similarity index 100% rename from test/fixtures/configTypeJsDeferred/serverless.js rename to test/fixtures/cli/configTypeJsDeferred/serverless.js diff --git a/test/fixtures/configTypeJson/serverless.json b/test/fixtures/cli/configTypeJson/serverless.json similarity index 100% rename from test/fixtures/configTypeJson/serverless.json rename to test/fixtures/cli/configTypeJson/serverless.json diff --git a/test/fixtures/configTypeNonObject/serverless.json b/test/fixtures/cli/configTypeNonObject/serverless.json similarity index 100% rename from test/fixtures/configTypeNonObject/serverless.json rename to test/fixtures/cli/configTypeNonObject/serverless.json diff --git a/test/fixtures/configTypeYaml/serverless.yaml b/test/fixtures/cli/configTypeYaml/serverless.yaml similarity index 100% rename from test/fixtures/configTypeYaml/serverless.yaml rename to test/fixtures/cli/configTypeYaml/serverless.yaml diff --git a/test/fixtures/configTypeYml/serverless.yml b/test/fixtures/cli/configTypeYml/serverless.yml similarity index 100% rename from test/fixtures/configTypeYml/serverless.yml rename to test/fixtures/cli/configTypeYml/serverless.yml diff --git a/test/fixtures/configTypeYmlAndJson/serverless.json b/test/fixtures/cli/configTypeYmlAndJson/serverless.json similarity index 100% rename from test/fixtures/configTypeYmlAndJson/serverless.json rename to test/fixtures/cli/configTypeYmlAndJson/serverless.json diff --git a/test/fixtures/configTypeYmlAndJson/serverless.yml b/test/fixtures/cli/configTypeYmlAndJson/serverless.yml similarity index 100% rename from test/fixtures/configTypeYmlAndJson/serverless.yml rename to test/fixtures/cli/configTypeYmlAndJson/serverless.yml diff --git a/test/fixtures/index.js b/test/fixtures/cli/index.js similarity index 100% rename from test/fixtures/index.js rename to test/fixtures/cli/index.js diff --git a/test/fixtures/serverlessTs/serverless.ts b/test/fixtures/cli/serverlessTs/serverless.ts similarity index 100% rename from test/fixtures/serverlessTs/serverless.ts rename to test/fixtures/cli/serverlessTs/serverless.ts diff --git a/test/fixtures/uncaughtException/plugin.js b/test/fixtures/cli/uncaughtException/plugin.js similarity index 100% rename from test/fixtures/uncaughtException/plugin.js rename to test/fixtures/cli/uncaughtException/plugin.js diff --git a/test/fixtures/exception/serverless.yml b/test/fixtures/cli/uncaughtException/serverless.yml similarity index 100% rename from test/fixtures/exception/serverless.yml rename to test/fixtures/cli/uncaughtException/serverless.yml diff --git a/test/fixtures/variables-legacy/config.json b/test/fixtures/cli/variables/config.json similarity index 100% rename from test/fixtures/variables-legacy/config.json rename to test/fixtures/cli/variables/config.json diff --git a/test/fixtures/variables/serverless.yml b/test/fixtures/cli/variables/serverless.yml similarity index 100% rename from test/fixtures/variables/serverless.yml rename to test/fixtures/cli/variables/serverless.yml diff --git a/test/fixtures/variables-legacy/terraform.tfstate b/test/fixtures/cli/variables/terraform.tfstate similarity index 100% rename from test/fixtures/variables-legacy/terraform.tfstate rename to test/fixtures/cli/variables/terraform.tfstate diff --git a/test/fixtures/apiGateway/index.js b/test/fixtures/programmatic/apiGateway/index.js similarity index 100% rename from test/fixtures/apiGateway/index.js rename to test/fixtures/programmatic/apiGateway/index.js diff --git a/test/fixtures/apiGateway/serverless.yml b/test/fixtures/programmatic/apiGateway/serverless.yml similarity index 100% rename from test/fixtures/apiGateway/serverless.yml rename to test/fixtures/programmatic/apiGateway/serverless.yml diff --git a/test/fixtures/apiGatewayExtended/core.js b/test/fixtures/programmatic/apiGatewayExtended/core.js similarity index 100% rename from test/fixtures/apiGatewayExtended/core.js rename to test/fixtures/programmatic/apiGatewayExtended/core.js diff --git a/test/fixtures/apiGatewayExtended/helper.js b/test/fixtures/programmatic/apiGatewayExtended/helper.js similarity index 100% rename from test/fixtures/apiGatewayExtended/helper.js rename to test/fixtures/programmatic/apiGatewayExtended/helper.js diff --git a/test/fixtures/apiGatewayExtended/serverless.yml b/test/fixtures/programmatic/apiGatewayExtended/serverless.yml similarity index 100% rename from test/fixtures/apiGatewayExtended/serverless.yml rename to test/fixtures/programmatic/apiGatewayExtended/serverless.yml diff --git a/test/fixtures/aws/serverless.yml b/test/fixtures/programmatic/aws/serverless.yml similarity index 100% rename from test/fixtures/aws/serverless.yml rename to test/fixtures/programmatic/aws/serverless.yml diff --git a/test/fixtures/programmatic/blank/serverless.yml b/test/fixtures/programmatic/blank/serverless.yml new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/test/fixtures/programmatic/blank/serverless.yml @@ -0,0 +1 @@ +{} diff --git a/test/fixtures/checkForChanges/artifact.zip b/test/fixtures/programmatic/checkForChanges/artifact.zip similarity index 100% rename from test/fixtures/checkForChanges/artifact.zip rename to test/fixtures/programmatic/checkForChanges/artifact.zip diff --git a/test/fixtures/checkForChanges/fn.js b/test/fixtures/programmatic/checkForChanges/fn.js similarity index 100% rename from test/fixtures/checkForChanges/fn.js rename to test/fixtures/programmatic/checkForChanges/fn.js diff --git a/test/fixtures/checkForChanges/fnIndividually.js b/test/fixtures/programmatic/checkForChanges/fnIndividually.js similarity index 100% rename from test/fixtures/checkForChanges/fnIndividually.js rename to test/fixtures/programmatic/checkForChanges/fnIndividually.js diff --git a/test/fixtures/checkForChanges/serverless.yml b/test/fixtures/programmatic/checkForChanges/serverless.yml similarity index 100% rename from test/fixtures/checkForChanges/serverless.yml rename to test/fixtures/programmatic/checkForChanges/serverless.yml diff --git a/test/fixtures/cognitoUserPool/core.js b/test/fixtures/programmatic/cognitoUserPool/core.js similarity index 100% rename from test/fixtures/cognitoUserPool/core.js rename to test/fixtures/programmatic/cognitoUserPool/core.js diff --git a/test/fixtures/cognitoUserPool/serverless.yml b/test/fixtures/programmatic/cognitoUserPool/serverless.yml similarity index 100% rename from test/fixtures/cognitoUserPool/serverless.yml rename to test/fixtures/programmatic/cognitoUserPool/serverless.yml diff --git a/test/fixtures/cognitoUserPool/utils.js b/test/fixtures/programmatic/cognitoUserPool/utils.js similarity index 100% rename from test/fixtures/cognitoUserPool/utils.js rename to test/fixtures/programmatic/cognitoUserPool/utils.js diff --git a/test/fixtures/configInvalid/serverless.yml b/test/fixtures/programmatic/configInvalid/serverless.yml similarity index 100% rename from test/fixtures/configInvalid/serverless.yml rename to test/fixtures/programmatic/configInvalid/serverless.yml diff --git a/test/fixtures/configSchemaExtensions/serverless.yml b/test/fixtures/programmatic/configSchemaExtensions/serverless.yml similarity index 100% rename from test/fixtures/configSchemaExtensions/serverless.yml rename to test/fixtures/programmatic/configSchemaExtensions/serverless.yml diff --git a/test/fixtures/configSchemaExtensions/test-plugin.js b/test/fixtures/programmatic/configSchemaExtensions/test-plugin.js similarity index 100% rename from test/fixtures/configSchemaExtensions/test-plugin.js rename to test/fixtures/programmatic/configSchemaExtensions/test-plugin.js diff --git a/test/fixtures/configSchemaExtensionsError/serverless.yml b/test/fixtures/programmatic/configSchemaExtensionsError/serverless.yml similarity index 100% rename from test/fixtures/configSchemaExtensionsError/serverless.yml rename to test/fixtures/programmatic/configSchemaExtensionsError/serverless.yml diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-custom-property.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-custom-property.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-custom-property.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-custom-property.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-event-property.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-event-property.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-event-property.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-event-property.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-event.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-event.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-event.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-event.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-property.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-property.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-function-property.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-function-property.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-function.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-function.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-function.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-function.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-provider.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-provider.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-provider.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-provider-property-in-provider.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-top-level-property.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-top-level-property.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-colliding-top-level-property.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-colliding-top-level-property.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-complex-event-without-object-definition.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-complex-event-without-object-definition.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-complex-event-without-object-definition.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-complex-event-without-object-definition.js diff --git a/test/fixtures/configSchemaExtensionsError/test-plugin-with-non-existing-event-error.js b/test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-non-existing-event-error.js similarity index 100% rename from test/fixtures/configSchemaExtensionsError/test-plugin-with-non-existing-event-error.js rename to test/fixtures/programmatic/configSchemaExtensionsError/test-plugin-with-non-existing-event-error.js diff --git a/test/fixtures/customProvider/customProvider.js b/test/fixtures/programmatic/customProvider/customProvider.js similarity index 100% rename from test/fixtures/customProvider/customProvider.js rename to test/fixtures/programmatic/customProvider/customProvider.js diff --git a/test/fixtures/customProvider/serverless.yml b/test/fixtures/programmatic/customProvider/serverless.yml similarity index 100% rename from test/fixtures/customProvider/serverless.yml rename to test/fixtures/programmatic/customProvider/serverless.yml diff --git a/test/fixtures/ecr/Dockerfile b/test/fixtures/programmatic/ecr/Dockerfile similarity index 100% rename from test/fixtures/ecr/Dockerfile rename to test/fixtures/programmatic/ecr/Dockerfile diff --git a/test/fixtures/ecr/Dockerfile.dev b/test/fixtures/programmatic/ecr/Dockerfile.dev similarity index 100% rename from test/fixtures/ecr/Dockerfile.dev rename to test/fixtures/programmatic/ecr/Dockerfile.dev diff --git a/test/fixtures/ecr/app.js b/test/fixtures/programmatic/ecr/app.js similarity index 100% rename from test/fixtures/ecr/app.js rename to test/fixtures/programmatic/ecr/app.js diff --git a/test/fixtures/ecr/serverless.yml b/test/fixtures/programmatic/ecr/serverless.yml similarity index 100% rename from test/fixtures/ecr/serverless.yml rename to test/fixtures/programmatic/ecr/serverless.yml diff --git a/test/fixtures/eventBridge/core.js b/test/fixtures/programmatic/eventBridge/core.js similarity index 100% rename from test/fixtures/eventBridge/core.js rename to test/fixtures/programmatic/eventBridge/core.js diff --git a/test/fixtures/eventBridge/serverless.yml b/test/fixtures/programmatic/eventBridge/serverless.yml similarity index 100% rename from test/fixtures/eventBridge/serverless.yml rename to test/fixtures/programmatic/eventBridge/serverless.yml diff --git a/test/fixtures/eventBridge/utils.js b/test/fixtures/programmatic/eventBridge/utils.js similarity index 100% rename from test/fixtures/eventBridge/utils.js rename to test/fixtures/programmatic/eventBridge/utils.js diff --git a/test/fixtures/exception/plugin.js b/test/fixtures/programmatic/exception/plugin.js similarity index 100% rename from test/fixtures/exception/plugin.js rename to test/fixtures/programmatic/exception/plugin.js diff --git a/test/fixtures/uncaughtException/serverless.yml b/test/fixtures/programmatic/exception/serverless.yml similarity index 100% rename from test/fixtures/uncaughtException/serverless.yml rename to test/fixtures/programmatic/exception/serverless.yml diff --git a/test/fixtures/function/index.js b/test/fixtures/programmatic/function/index.js similarity index 100% rename from test/fixtures/function/index.js rename to test/fixtures/programmatic/function/index.js diff --git a/test/fixtures/function/serverless.yml b/test/fixtures/programmatic/function/serverless.yml similarity index 100% rename from test/fixtures/function/serverless.yml rename to test/fixtures/programmatic/function/serverless.yml diff --git a/test/fixtures/functionCloudFront/index.js b/test/fixtures/programmatic/functionCloudFront/index.js similarity index 100% rename from test/fixtures/functionCloudFront/index.js rename to test/fixtures/programmatic/functionCloudFront/index.js diff --git a/test/fixtures/functionCloudFront/serverless.yml b/test/fixtures/programmatic/functionCloudFront/serverless.yml similarity index 100% rename from test/fixtures/functionCloudFront/serverless.yml rename to test/fixtures/programmatic/functionCloudFront/serverless.yml diff --git a/test/fixtures/functionDestinations/serverless.yml b/test/fixtures/programmatic/functionDestinations/serverless.yml similarity index 100% rename from test/fixtures/functionDestinations/serverless.yml rename to test/fixtures/programmatic/functionDestinations/serverless.yml diff --git a/test/fixtures/functionDestinations/target.js b/test/fixtures/programmatic/functionDestinations/target.js similarity index 100% rename from test/fixtures/functionDestinations/target.js rename to test/fixtures/programmatic/functionDestinations/target.js diff --git a/test/fixtures/functionDestinations/trigger.js b/test/fixtures/programmatic/functionDestinations/trigger.js similarity index 100% rename from test/fixtures/functionDestinations/trigger.js rename to test/fixtures/programmatic/functionDestinations/trigger.js diff --git a/test/fixtures/functionEfs/core.js b/test/fixtures/programmatic/functionEfs/core.js similarity index 100% rename from test/fixtures/functionEfs/core.js rename to test/fixtures/programmatic/functionEfs/core.js diff --git a/test/fixtures/functionEfs/serverless.yml b/test/fixtures/programmatic/functionEfs/serverless.yml similarity index 100% rename from test/fixtures/functionEfs/serverless.yml rename to test/fixtures/programmatic/functionEfs/serverless.yml diff --git a/test/fixtures/functionLayers/extra_layers/testLayerSourceChange/index.js b/test/fixtures/programmatic/functionLayers/extra_layers/testLayerSourceChange/index.js similarity index 100% rename from test/fixtures/functionLayers/extra_layers/testLayerSourceChange/index.js rename to test/fixtures/programmatic/functionLayers/extra_layers/testLayerSourceChange/index.js diff --git a/test/fixtures/functionLayers/index.js b/test/fixtures/programmatic/functionLayers/index.js similarity index 100% rename from test/fixtures/functionLayers/index.js rename to test/fixtures/programmatic/functionLayers/index.js diff --git a/test/fixtures/functionLayers/serverless.yml b/test/fixtures/programmatic/functionLayers/serverless.yml similarity index 100% rename from test/fixtures/functionLayers/serverless.yml rename to test/fixtures/programmatic/functionLayers/serverless.yml diff --git a/test/fixtures/functionLayers/testLayer/index.js b/test/fixtures/programmatic/functionLayers/testLayer/index.js similarity index 100% rename from test/fixtures/functionLayers/testLayer/index.js rename to test/fixtures/programmatic/functionLayers/testLayer/index.js diff --git a/test/fixtures/functionMsk/core.js b/test/fixtures/programmatic/functionMsk/core.js similarity index 100% rename from test/fixtures/functionMsk/core.js rename to test/fixtures/programmatic/functionMsk/core.js diff --git a/test/fixtures/functionMsk/package.json b/test/fixtures/programmatic/functionMsk/package.json similarity index 100% rename from test/fixtures/functionMsk/package.json rename to test/fixtures/programmatic/functionMsk/package.json diff --git a/test/fixtures/functionMsk/serverless.yml b/test/fixtures/programmatic/functionMsk/serverless.yml similarity index 100% rename from test/fixtures/functionMsk/serverless.yml rename to test/fixtures/programmatic/functionMsk/serverless.yml diff --git a/test/fixtures/httpApi/authorizers.js b/test/fixtures/programmatic/httpApi/authorizers.js similarity index 100% rename from test/fixtures/httpApi/authorizers.js rename to test/fixtures/programmatic/httpApi/authorizers.js diff --git a/test/fixtures/httpApi/index.js b/test/fixtures/programmatic/httpApi/index.js similarity index 100% rename from test/fixtures/httpApi/index.js rename to test/fixtures/programmatic/httpApi/index.js diff --git a/test/fixtures/httpApi/serverless.yml b/test/fixtures/programmatic/httpApi/serverless.yml similarity index 100% rename from test/fixtures/httpApi/serverless.yml rename to test/fixtures/programmatic/httpApi/serverless.yml diff --git a/test/fixtures/httpApiCatchAll/index.js b/test/fixtures/programmatic/httpApiCatchAll/index.js similarity index 100% rename from test/fixtures/httpApiCatchAll/index.js rename to test/fixtures/programmatic/httpApiCatchAll/index.js diff --git a/test/fixtures/httpApiCatchAll/serverless.yml b/test/fixtures/programmatic/httpApiCatchAll/serverless.yml similarity index 100% rename from test/fixtures/httpApiCatchAll/serverless.yml rename to test/fixtures/programmatic/httpApiCatchAll/serverless.yml diff --git a/test/fixtures/httpApiExport/serverless.yml b/test/fixtures/programmatic/httpApiExport/serverless.yml similarity index 100% rename from test/fixtures/httpApiExport/serverless.yml rename to test/fixtures/programmatic/httpApiExport/serverless.yml diff --git a/test/fixtures/programmatic/index.js b/test/fixtures/programmatic/index.js new file mode 100644 index 00000000000..467a7bf4b01 --- /dev/null +++ b/test/fixtures/programmatic/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('@serverless/test/setup-fixtures-engine')(__dirname); diff --git a/test/fixtures/invocation/async.js b/test/fixtures/programmatic/invocation/async.js similarity index 100% rename from test/fixtures/invocation/async.js rename to test/fixtures/programmatic/invocation/async.js diff --git a/test/fixtures/invocation/callback.js b/test/fixtures/programmatic/invocation/callback.js similarity index 100% rename from test/fixtures/invocation/callback.js rename to test/fixtures/programmatic/invocation/callback.js diff --git a/test/fixtures/invocation/context-done.js b/test/fixtures/programmatic/invocation/context-done.js similarity index 100% rename from test/fixtures/invocation/context-done.js rename to test/fixtures/programmatic/invocation/context-done.js diff --git a/test/fixtures/invocation/context-succeed.js b/test/fixtures/programmatic/invocation/context-succeed.js similarity index 100% rename from test/fixtures/invocation/context-succeed.js rename to test/fixtures/programmatic/invocation/context-succeed.js diff --git a/test/fixtures/invocation/context.json b/test/fixtures/programmatic/invocation/context.json similarity index 100% rename from test/fixtures/invocation/context.json rename to test/fixtures/programmatic/invocation/context.json diff --git a/test/fixtures/invocation/doubled-resolution-callback-first.js b/test/fixtures/programmatic/invocation/doubled-resolution-callback-first.js similarity index 100% rename from test/fixtures/invocation/doubled-resolution-callback-first.js rename to test/fixtures/programmatic/invocation/doubled-resolution-callback-first.js diff --git a/test/fixtures/invocation/doubled-resolution-promise-first.js b/test/fixtures/programmatic/invocation/doubled-resolution-promise-first.js similarity index 100% rename from test/fixtures/invocation/doubled-resolution-promise-first.js rename to test/fixtures/programmatic/invocation/doubled-resolution-promise-first.js diff --git a/test/fixtures/invocation/init-fail.js b/test/fixtures/programmatic/invocation/init-fail.js similarity index 100% rename from test/fixtures/invocation/init-fail.js rename to test/fixtures/programmatic/invocation/init-fail.js diff --git a/test/fixtures/invocation/invocation-fail.js b/test/fixtures/programmatic/invocation/invocation-fail.js similarity index 100% rename from test/fixtures/invocation/invocation-fail.js rename to test/fixtures/programmatic/invocation/invocation-fail.js diff --git a/test/fixtures/invocation/payload.js b/test/fixtures/programmatic/invocation/payload.js similarity index 100% rename from test/fixtures/invocation/payload.js rename to test/fixtures/programmatic/invocation/payload.js diff --git a/test/fixtures/invocation/payload.json b/test/fixtures/programmatic/invocation/payload.json similarity index 100% rename from test/fixtures/invocation/payload.json rename to test/fixtures/programmatic/invocation/payload.json diff --git a/test/fixtures/invocation/payload.yaml b/test/fixtures/programmatic/invocation/payload.yaml similarity index 100% rename from test/fixtures/invocation/payload.yaml rename to test/fixtures/programmatic/invocation/payload.yaml diff --git a/test/fixtures/invocation/remaining-time.js b/test/fixtures/programmatic/invocation/remaining-time.js similarity index 100% rename from test/fixtures/invocation/remaining-time.js rename to test/fixtures/programmatic/invocation/remaining-time.js diff --git a/test/fixtures/invocation/serverless.yml b/test/fixtures/programmatic/invocation/serverless.yml similarity index 100% rename from test/fixtures/invocation/serverless.yml rename to test/fixtures/programmatic/invocation/serverless.yml diff --git a/test/fixtures/iot/core.js b/test/fixtures/programmatic/iot/core.js similarity index 100% rename from test/fixtures/iot/core.js rename to test/fixtures/programmatic/iot/core.js diff --git a/test/fixtures/iot/serverless.yml b/test/fixtures/programmatic/iot/serverless.yml similarity index 100% rename from test/fixtures/iot/serverless.yml rename to test/fixtures/programmatic/iot/serverless.yml diff --git a/test/fixtures/iot/utils.js b/test/fixtures/programmatic/iot/utils.js similarity index 100% rename from test/fixtures/iot/utils.js rename to test/fixtures/programmatic/iot/utils.js diff --git a/test/fixtures/iotFleetProvisioning/hook.js b/test/fixtures/programmatic/iotFleetProvisioning/hook.js similarity index 100% rename from test/fixtures/iotFleetProvisioning/hook.js rename to test/fixtures/programmatic/iotFleetProvisioning/hook.js diff --git a/test/fixtures/iotFleetProvisioning/package.json b/test/fixtures/programmatic/iotFleetProvisioning/package.json similarity index 100% rename from test/fixtures/iotFleetProvisioning/package.json rename to test/fixtures/programmatic/iotFleetProvisioning/package.json diff --git a/test/fixtures/iotFleetProvisioning/registerDevice.js b/test/fixtures/programmatic/iotFleetProvisioning/registerDevice.js similarity index 100% rename from test/fixtures/iotFleetProvisioning/registerDevice.js rename to test/fixtures/programmatic/iotFleetProvisioning/registerDevice.js diff --git a/test/fixtures/iotFleetProvisioning/serverless.yml b/test/fixtures/programmatic/iotFleetProvisioning/serverless.yml similarity index 100% rename from test/fixtures/iotFleetProvisioning/serverless.yml rename to test/fixtures/programmatic/iotFleetProvisioning/serverless.yml diff --git a/test/fixtures/iotFleetProvisioning/template.json b/test/fixtures/programmatic/iotFleetProvisioning/template.json similarity index 100% rename from test/fixtures/iotFleetProvisioning/template.json rename to test/fixtures/programmatic/iotFleetProvisioning/template.json diff --git a/test/fixtures/layer/index.js b/test/fixtures/programmatic/layer/index.js similarity index 100% rename from test/fixtures/layer/index.js rename to test/fixtures/programmatic/layer/index.js diff --git a/test/fixtures/layer/layer/index.js b/test/fixtures/programmatic/layer/layer/index.js similarity index 100% rename from test/fixtures/layer/layer/index.js rename to test/fixtures/programmatic/layer/layer/index.js diff --git a/test/fixtures/layer/serverless.yml b/test/fixtures/programmatic/layer/serverless.yml similarity index 100% rename from test/fixtures/layer/serverless.yml rename to test/fixtures/programmatic/layer/serverless.yml diff --git a/test/fixtures/locallyInstalledServerless/_setup.js b/test/fixtures/programmatic/locallyInstalledServerless/_setup.js similarity index 98% rename from test/fixtures/locallyInstalledServerless/_setup.js rename to test/fixtures/programmatic/locallyInstalledServerless/_setup.js index 29c9d54401d..08248290f87 100644 --- a/test/fixtures/locallyInstalledServerless/_setup.js +++ b/test/fixtures/programmatic/locallyInstalledServerless/_setup.js @@ -12,7 +12,7 @@ module.exports = (originalFixturePath) => { fixtureModulePath, String(content).replace( '$SERVERLESS_PATH', - JSON.stringify(path.resolve(originalFixturePath, '../../../')) + JSON.stringify(path.resolve(originalFixturePath, '../../../../')) ) ); }; diff --git a/test/fixtures/locallyInstalledServerless/node_modules/serverless/index.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/index.js similarity index 51% rename from test/fixtures/locallyInstalledServerless/node_modules/serverless/index.js rename to test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/index.js index 50d600c5d53..c27790f0783 100644 --- a/test/fixtures/locallyInstalledServerless/node_modules/serverless/index.js +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/index.js @@ -1,9 +1,11 @@ 'use strict'; // eslint-disable-next-line no-undef -const Serverless = require($SERVERLESS_PATH); +const SERVERLESS_PATH = $SERVERLESS_PATH; -module.exports = class LocalServerless extends Serverless { +const Serverless = require(SERVERLESS_PATH); + +class LocalServerless extends Serverless { constructor(config) { super(config); this.isLocalStub = true; @@ -13,3 +15,7 @@ module.exports = class LocalServerless extends Serverless { return Promise.resolve(); } }; + +LocalServerless.SERVERLESS_PATH = SERVERLESS_PATH; + +module.exports = LocalServerless; diff --git a/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/commands-schema.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/commands-schema.js new file mode 100644 index 00000000000..91fd86eb0ba --- /dev/null +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/commands-schema.js @@ -0,0 +1,5 @@ +'use strict'; + +const path = require('path'); + +module.exports = require(path.resolve(require('../../').SERVERLESS_PATH, 'lib/cli/commands-schema')); diff --git a/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-configuration-path.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-configuration-path.js new file mode 100644 index 00000000000..3aa0d60cb8c --- /dev/null +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-configuration-path.js @@ -0,0 +1,5 @@ +'use strict'; + +const path = require('path'); + +module.exports = require(path.resolve(require('../..').SERVERLESS_PATH, 'lib/cli/resolve-configuration-path')); diff --git a/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-input.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-input.js new file mode 100644 index 00000000000..f7907d4db55 --- /dev/null +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/cli/resolve-input.js @@ -0,0 +1,5 @@ +'use strict'; + +const path = require('path'); + +module.exports = require(path.resolve(require('../..').SERVERLESS_PATH, 'lib/cli/resolve-input')); diff --git a/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/read.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/read.js new file mode 100644 index 00000000000..f0c2a10a275 --- /dev/null +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/read.js @@ -0,0 +1,5 @@ +'use strict'; + +const path = require('path'); + +module.exports = require(path.resolve(require('../..').SERVERLESS_PATH, 'lib/configuration/read')); diff --git a/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/variables.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/variables.js new file mode 100644 index 00000000000..01bb118433f --- /dev/null +++ b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/configuration/variables.js @@ -0,0 +1,5 @@ +'use strict'; + +const path = require('path'); + +module.exports = require(path.resolve(require('../..').SERVERLESS_PATH, 'lib/configuration/variables')); diff --git a/test/fixtures/locallyInstalledServerless/node_modules/serverless/lib/utils/analytics/areDisabled.js b/test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/utils/analytics/areDisabled.js similarity index 100% rename from test/fixtures/locallyInstalledServerless/node_modules/serverless/lib/utils/analytics/areDisabled.js rename to test/fixtures/programmatic/locallyInstalledServerless/node_modules/serverless/lib/utils/analytics/areDisabled.js diff --git a/test/fixtures/locallyInstalledServerless/serverless.yml b/test/fixtures/programmatic/locallyInstalledServerless/serverless.yml similarity index 100% rename from test/fixtures/locallyInstalledServerless/serverless.yml rename to test/fixtures/programmatic/locallyInstalledServerless/serverless.yml diff --git a/test/fixtures/packageArtifact/absoluteArtifact.zip b/test/fixtures/programmatic/packageArtifact/absoluteArtifact.zip similarity index 100% rename from test/fixtures/packageArtifact/absoluteArtifact.zip rename to test/fixtures/programmatic/packageArtifact/absoluteArtifact.zip diff --git a/test/fixtures/packageArtifact/artifact-function.zip b/test/fixtures/programmatic/packageArtifact/artifact-function.zip similarity index 100% rename from test/fixtures/packageArtifact/artifact-function.zip rename to test/fixtures/programmatic/packageArtifact/artifact-function.zip diff --git a/test/fixtures/packageArtifact/artifact.zip b/test/fixtures/programmatic/packageArtifact/artifact.zip similarity index 100% rename from test/fixtures/packageArtifact/artifact.zip rename to test/fixtures/programmatic/packageArtifact/artifact.zip diff --git a/test/fixtures/packageArtifact/index.js b/test/fixtures/programmatic/packageArtifact/index.js similarity index 100% rename from test/fixtures/packageArtifact/index.js rename to test/fixtures/programmatic/packageArtifact/index.js diff --git a/test/fixtures/packageArtifact/serverless.yml b/test/fixtures/programmatic/packageArtifact/serverless.yml similarity index 100% rename from test/fixtures/packageArtifact/serverless.yml rename to test/fixtures/programmatic/packageArtifact/serverless.yml diff --git a/test/fixtures/packageArtifactInServerlessDir/my-own.zip b/test/fixtures/programmatic/packageArtifactInServerlessDir/my-own.zip similarity index 100% rename from test/fixtures/packageArtifactInServerlessDir/my-own.zip rename to test/fixtures/programmatic/packageArtifactInServerlessDir/my-own.zip diff --git a/test/fixtures/packageArtifactInServerlessDir/package-artifact-plugin.js b/test/fixtures/programmatic/packageArtifactInServerlessDir/package-artifact-plugin.js similarity index 100% rename from test/fixtures/packageArtifactInServerlessDir/package-artifact-plugin.js rename to test/fixtures/programmatic/packageArtifactInServerlessDir/package-artifact-plugin.js diff --git a/test/fixtures/packageArtifactInServerlessDir/serverless.yml b/test/fixtures/programmatic/packageArtifactInServerlessDir/serverless.yml similarity index 100% rename from test/fixtures/packageArtifactInServerlessDir/serverless.yml rename to test/fixtures/programmatic/packageArtifactInServerlessDir/serverless.yml diff --git a/test/fixtures/packaging/.env b/test/fixtures/programmatic/packaging/.env similarity index 100% rename from test/fixtures/packaging/.env rename to test/fixtures/programmatic/packaging/.env diff --git a/test/fixtures/packaging/.env.stage b/test/fixtures/programmatic/packaging/.env.stage similarity index 100% rename from test/fixtures/packaging/.env.stage rename to test/fixtures/programmatic/packaging/.env.stage diff --git a/test/fixtures/packaging/.gitignore b/test/fixtures/programmatic/packaging/.gitignore similarity index 100% rename from test/fixtures/packaging/.gitignore rename to test/fixtures/programmatic/packaging/.gitignore diff --git a/test/fixtures/packaging/.serverless_plugins/index.js b/test/fixtures/programmatic/packaging/.serverless_plugins/index.js similarity index 100% rename from test/fixtures/packaging/.serverless_plugins/index.js rename to test/fixtures/programmatic/packaging/.serverless_plugins/index.js diff --git a/test/fixtures/packaging/artifact-function.zip b/test/fixtures/programmatic/packaging/artifact-function.zip similarity index 100% rename from test/fixtures/packaging/artifact-function.zip rename to test/fixtures/programmatic/packaging/artifact-function.zip diff --git a/test/fixtures/packaging/artifact.zip b/test/fixtures/programmatic/packaging/artifact.zip similarity index 100% rename from test/fixtures/packaging/artifact.zip rename to test/fixtures/programmatic/packaging/artifact.zip diff --git a/test/fixtures/packaging/custom-plugins/index.js b/test/fixtures/programmatic/packaging/custom-plugins/index.js similarity index 100% rename from test/fixtures/packaging/custom-plugins/index.js rename to test/fixtures/programmatic/packaging/custom-plugins/index.js diff --git a/test/fixtures/packaging/dir1/index.js b/test/fixtures/programmatic/packaging/dir1/index.js similarity index 100% rename from test/fixtures/packaging/dir1/index.js rename to test/fixtures/programmatic/packaging/dir1/index.js diff --git a/test/fixtures/packaging/dir1/subdir1/index.js b/test/fixtures/programmatic/packaging/dir1/subdir1/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir1/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir1/index.js diff --git a/test/fixtures/packaging/dir1/subdir2/index.js b/test/fixtures/programmatic/packaging/dir1/subdir2/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir2/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir2/index.js diff --git a/test/fixtures/packaging/dir1/subdir2/subsubdir1/index.js b/test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir1/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir2/subsubdir1/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir1/index.js diff --git a/test/fixtures/packaging/dir1/subdir2/subsubdir2/index.js b/test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir2/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir2/subsubdir2/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir2/index.js diff --git a/test/fixtures/packaging/dir1/subdir2/subsubdir3/index.js b/test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir3/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir2/subsubdir3/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir2/subsubdir3/index.js diff --git a/test/fixtures/packaging/dir1/subdir3/index.js b/test/fixtures/programmatic/packaging/dir1/subdir3/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir3/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir3/index.js diff --git a/test/fixtures/packaging/dir1/subdir4/index.js b/test/fixtures/programmatic/packaging/dir1/subdir4/index.js similarity index 100% rename from test/fixtures/packaging/dir1/subdir4/index.js rename to test/fixtures/programmatic/packaging/dir1/subdir4/index.js diff --git a/test/fixtures/packaging/dir2/index.js b/test/fixtures/programmatic/packaging/dir2/index.js similarity index 100% rename from test/fixtures/packaging/dir2/index.js rename to test/fixtures/programmatic/packaging/dir2/index.js diff --git a/test/fixtures/packaging/dir3/index.js b/test/fixtures/programmatic/packaging/dir3/index.js similarity index 100% rename from test/fixtures/packaging/dir3/index.js rename to test/fixtures/programmatic/packaging/dir3/index.js diff --git a/test/fixtures/packaging/index.js b/test/fixtures/programmatic/packaging/index.js similarity index 100% rename from test/fixtures/packaging/index.js rename to test/fixtures/programmatic/packaging/index.js diff --git a/test/fixtures/packaging/layer/layer-module-1.js b/test/fixtures/programmatic/packaging/layer/layer-module-1.js similarity index 100% rename from test/fixtures/packaging/layer/layer-module-1.js rename to test/fixtures/programmatic/packaging/layer/layer-module-1.js diff --git a/test/fixtures/packaging/layer/layer-module-2.js b/test/fixtures/programmatic/packaging/layer/layer-module-2.js similarity index 100% rename from test/fixtures/packaging/layer/layer-module-2.js rename to test/fixtures/programmatic/packaging/layer/layer-module-2.js diff --git a/test/fixtures/packaging/main.go b/test/fixtures/programmatic/packaging/main.go similarity index 100% rename from test/fixtures/packaging/main.go rename to test/fixtures/programmatic/packaging/main.go diff --git a/test/fixtures/packaging/serverless.yml b/test/fixtures/programmatic/packaging/serverless.yml similarity index 100% rename from test/fixtures/packaging/serverless.yml rename to test/fixtures/programmatic/packaging/serverless.yml diff --git a/test/fixtures/plugin/plugin.js b/test/fixtures/programmatic/plugin/plugin.js similarity index 100% rename from test/fixtures/plugin/plugin.js rename to test/fixtures/programmatic/plugin/plugin.js diff --git a/test/fixtures/plugin/serverless.yml b/test/fixtures/programmatic/plugin/serverless.yml similarity index 100% rename from test/fixtures/plugin/serverless.yml rename to test/fixtures/programmatic/plugin/serverless.yml diff --git a/test/fixtures/provisionedConcurrency/core.js b/test/fixtures/programmatic/provisionedConcurrency/core.js similarity index 100% rename from test/fixtures/provisionedConcurrency/core.js rename to test/fixtures/programmatic/provisionedConcurrency/core.js diff --git a/test/fixtures/provisionedConcurrency/serverless.yml b/test/fixtures/programmatic/provisionedConcurrency/serverless.yml similarity index 100% rename from test/fixtures/provisionedConcurrency/serverless.yml rename to test/fixtures/programmatic/provisionedConcurrency/serverless.yml diff --git a/test/fixtures/requestSchema/dummySchema.json b/test/fixtures/programmatic/requestSchema/dummySchema.json similarity index 100% rename from test/fixtures/requestSchema/dummySchema.json rename to test/fixtures/programmatic/requestSchema/dummySchema.json diff --git a/test/fixtures/requestSchema/serverless.yml b/test/fixtures/programmatic/requestSchema/serverless.yml similarity index 100% rename from test/fixtures/requestSchema/serverless.yml rename to test/fixtures/programmatic/requestSchema/serverless.yml diff --git a/test/fixtures/requestSchema/target.js b/test/fixtures/programmatic/requestSchema/target.js similarity index 100% rename from test/fixtures/requestSchema/target.js rename to test/fixtures/programmatic/requestSchema/target.js diff --git a/test/fixtures/s3/core.js b/test/fixtures/programmatic/s3/core.js similarity index 100% rename from test/fixtures/s3/core.js rename to test/fixtures/programmatic/s3/core.js diff --git a/test/fixtures/s3/serverless.yml b/test/fixtures/programmatic/s3/serverless.yml similarity index 100% rename from test/fixtures/s3/serverless.yml rename to test/fixtures/programmatic/s3/serverless.yml diff --git a/test/fixtures/s3/utils.js b/test/fixtures/programmatic/s3/utils.js similarity index 100% rename from test/fixtures/s3/utils.js rename to test/fixtures/programmatic/s3/utils.js diff --git a/test/fixtures/schedule/core.js b/test/fixtures/programmatic/schedule/core.js similarity index 100% rename from test/fixtures/schedule/core.js rename to test/fixtures/programmatic/schedule/core.js diff --git a/test/fixtures/schedule/serverless.yml b/test/fixtures/programmatic/schedule/serverless.yml similarity index 100% rename from test/fixtures/schedule/serverless.yml rename to test/fixtures/programmatic/schedule/serverless.yml diff --git a/test/fixtures/schedule/utils.js b/test/fixtures/programmatic/schedule/utils.js similarity index 100% rename from test/fixtures/schedule/utils.js rename to test/fixtures/programmatic/schedule/utils.js diff --git a/test/fixtures/sns/core.js b/test/fixtures/programmatic/sns/core.js similarity index 100% rename from test/fixtures/sns/core.js rename to test/fixtures/programmatic/sns/core.js diff --git a/test/fixtures/sns/serverless.yml b/test/fixtures/programmatic/sns/serverless.yml similarity index 100% rename from test/fixtures/sns/serverless.yml rename to test/fixtures/programmatic/sns/serverless.yml diff --git a/test/fixtures/sns/utils.js b/test/fixtures/programmatic/sns/utils.js similarity index 100% rename from test/fixtures/sns/utils.js rename to test/fixtures/programmatic/sns/utils.js diff --git a/test/fixtures/sqs/core.js b/test/fixtures/programmatic/sqs/core.js similarity index 100% rename from test/fixtures/sqs/core.js rename to test/fixtures/programmatic/sqs/core.js diff --git a/test/fixtures/sqs/serverless.yml b/test/fixtures/programmatic/sqs/serverless.yml similarity index 100% rename from test/fixtures/sqs/serverless.yml rename to test/fixtures/programmatic/sqs/serverless.yml diff --git a/test/fixtures/sqs/utils.js b/test/fixtures/programmatic/sqs/utils.js similarity index 100% rename from test/fixtures/sqs/utils.js rename to test/fixtures/programmatic/sqs/utils.js diff --git a/test/fixtures/stream/core.js b/test/fixtures/programmatic/stream/core.js similarity index 100% rename from test/fixtures/stream/core.js rename to test/fixtures/programmatic/stream/core.js diff --git a/test/fixtures/stream/serverless.yml b/test/fixtures/programmatic/stream/serverless.yml similarity index 100% rename from test/fixtures/stream/serverless.yml rename to test/fixtures/programmatic/stream/serverless.yml diff --git a/test/fixtures/stream/utils.js b/test/fixtures/programmatic/stream/utils.js similarity index 100% rename from test/fixtures/stream/utils.js rename to test/fixtures/programmatic/stream/utils.js diff --git a/test/fixtures/variables/config.json b/test/fixtures/programmatic/variables-legacy/config.json similarity index 100% rename from test/fixtures/variables/config.json rename to test/fixtures/programmatic/variables-legacy/config.json diff --git a/test/fixtures/variables-legacy/serverless.yml b/test/fixtures/programmatic/variables-legacy/serverless.yml similarity index 100% rename from test/fixtures/variables-legacy/serverless.yml rename to test/fixtures/programmatic/variables-legacy/serverless.yml diff --git a/test/fixtures/variables/terraform.tfstate b/test/fixtures/programmatic/variables-legacy/terraform.tfstate similarity index 100% rename from test/fixtures/variables/terraform.tfstate rename to test/fixtures/programmatic/variables-legacy/terraform.tfstate diff --git a/test/fixtures/websocket/core.js b/test/fixtures/programmatic/websocket/core.js similarity index 100% rename from test/fixtures/websocket/core.js rename to test/fixtures/programmatic/websocket/core.js diff --git a/test/fixtures/websocket/serverless.yml b/test/fixtures/programmatic/websocket/serverless.yml similarity index 100% rename from test/fixtures/websocket/serverless.yml rename to test/fixtures/programmatic/websocket/serverless.yml diff --git a/test/integration/apiGateway.test.js b/test/integration/apiGateway.test.js index 86f983bf45e..fe26981c509 100644 --- a/test/integration/apiGateway.test.js +++ b/test/integration/apiGateway.test.js @@ -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'); diff --git a/test/integration/apiGatewayExternal.test.js b/test/integration/apiGatewayExternal.test.js index 6282daf79c9..1421d4fb977 100644 --- a/test/integration/apiGatewayExternal.test.js +++ b/test/integration/apiGatewayExternal.test.js @@ -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'); diff --git a/test/integration/cognitoUserPool.test.js b/test/integration/cognitoUserPool.test.js index bbeb414377e..510333b09af 100644 --- a/test/integration/cognitoUserPool.test.js +++ b/test/integration/cognitoUserPool.test.js @@ -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, diff --git a/test/integration/eventBridge.test.js b/test/integration/eventBridge.test.js index 3aa6fea304e..61168c94f9b 100644 --- a/test/integration/eventBridge.test.js +++ b/test/integration/eventBridge.test.js @@ -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 { diff --git a/test/integration/functionDestinations.test.js b/test/integration/functionDestinations.test.js index 6665079b837..27d379dd695 100644 --- a/test/integration/functionDestinations.test.js +++ b/test/integration/functionDestinations.test.js @@ -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'); diff --git a/test/integration/httpApi.test.js b/test/integration/httpApi.test.js index 74b5846d178..50e265b37d2 100644 --- a/test/integration/httpApi.test.js +++ b/test/integration/httpApi.test.js @@ -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'); diff --git a/test/integration/infra-dependent/fileSystemConfig.test.js b/test/integration/infra-dependent/fileSystemConfig.test.js index 556a21e0753..6976d505805 100644 --- a/test/integration/infra-dependent/fileSystemConfig.test.js +++ b/test/integration/infra-dependent/fileSystemConfig.test.js @@ -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'); diff --git a/test/integration/infra-dependent/msk.test.js b/test/integration/infra-dependent/msk.test.js index eba05b64903..5a8ec61355e 100644 --- a/test/integration/infra-dependent/msk.test.js +++ b/test/integration/infra-dependent/msk.test.js @@ -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, diff --git a/test/integration/iot.test.js b/test/integration/iot.test.js index 9ffde3490da..c4e2a7bfc42 100644 --- a/test/integration/iot.test.js +++ b/test/integration/iot.test.js @@ -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'); diff --git a/test/integration/iotFleetProvisioning.test.js b/test/integration/iotFleetProvisioning.test.js index f73db22cffd..4c91218a891 100644 --- a/test/integration/iotFleetProvisioning.test.js +++ b/test/integration/iotFleetProvisioning.test.js @@ -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'); diff --git a/test/integration/provisionedConcurrency.test.js b/test/integration/provisionedConcurrency.test.js index 027cd62e820..28cb404f587 100644 --- a/test/integration/provisionedConcurrency.test.js +++ b/test/integration/provisionedConcurrency.test.js @@ -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'); diff --git a/test/integration/s3.test.js b/test/integration/s3.test.js index 453ad7248a7..fb9ee556e10 100644 --- a/test/integration/s3.test.js +++ b/test/integration/s3.test.js @@ -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'); diff --git a/test/integration/schedule.test.js b/test/integration/schedule.test.js index 64a8d1d4282..3d88843a54c 100644 --- a/test/integration/schedule.test.js +++ b/test/integration/schedule.test.js @@ -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'); diff --git a/test/integration/sns.test.js b/test/integration/sns.test.js index 40856431a02..6d5d766a033 100644 --- a/test/integration/sns.test.js +++ b/test/integration/sns.test.js @@ -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'); diff --git a/test/integration/sqs.test.js b/test/integration/sqs.test.js index 97041077412..e836e14d9c9 100644 --- a/test/integration/sqs.test.js +++ b/test/integration/sqs.test.js @@ -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'); diff --git a/test/integration/stream.test.js b/test/integration/stream.test.js index a3edc9120f8..66d3eefe432 100644 --- a/test/integration/stream.test.js +++ b/test/integration/stream.test.js @@ -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'); diff --git a/test/integration/websocket.test.js b/test/integration/websocket.test.js index ac6d27734b0..832843c91c1 100644 --- a/test/integration/websocket.test.js +++ b/test/integration/websocket.test.js @@ -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'); diff --git a/test/unit/lib/Serverless.test.js b/test/unit/lib/Serverless.test.js index 9c2d7e60dce..6eedff197d9 100644 --- a/test/unit/lib/Serverless.test.js +++ b/test/unit/lib/Serverless.test.js @@ -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', () => { @@ -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([]); @@ -242,7 +242,7 @@ describe('Serverless [new tests]', () => { runServerless({ fixture: 'locallyInstalledServerless', configExt: { enableLocalInstallationFallback: false }, - cliArgs: ['-v'], + command: 'print', modulesCacheStub: {}, }).then(({ serverless }) => { serverlessWithDisabledLocalInstallationFallback = serverless; @@ -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([ @@ -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' @@ -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; @@ -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'); @@ -342,7 +343,7 @@ describe('Serverless [new tests]', () => { before(async () => { ({ serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['package'], + command: 'package', })); }); diff --git a/test/unit/lib/classes/ConfigSchemaHandler/index.test.js b/test/unit/lib/classes/ConfigSchemaHandler/index.test.js index 6acbacd6987..d1054c7bfbe 100644 --- a/test/unit/lib/classes/ConfigSchemaHandler/index.test.js +++ b/test/unit/lib/classes/ConfigSchemaHandler/index.test.js @@ -13,7 +13,7 @@ describe('ConfigSchemaHandler', () => { it('should freeze parts of schema for service', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { expect(() => { serverless.configSchemaHandler.schema.properties.service.name = 'changed'; @@ -24,7 +24,7 @@ describe('ConfigSchemaHandler', () => { it('should freeze parts of schema for plugins', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { expect(() => { serverless.configSchemaHandler.schema.properties.plugins.properties = 'changed'; @@ -35,7 +35,7 @@ describe('ConfigSchemaHandler', () => { it('should freeze parts of schema for resources', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { expect(() => { serverless.configSchemaHandler.schema.properties.resources.something = 'changed'; @@ -46,7 +46,7 @@ describe('ConfigSchemaHandler', () => { it('should freeze parts of schema for package', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { expect(() => { serverless.configSchemaHandler.schema.properties.package.properties.oneMore = { @@ -59,7 +59,7 @@ describe('ConfigSchemaHandler', () => { it('should freeze parts of schema for layers', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { expect(() => { serverless.configSchemaHandler.schema.properties.layers.properties = 'changed'; @@ -72,7 +72,7 @@ describe('ConfigSchemaHandler', () => { it('should run without errors for valid config', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }); }); }); @@ -81,7 +81,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineFunctionEvent method', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { const expectedPieceOfSchema = { type: 'object', @@ -115,7 +115,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-function-event'], }, @@ -128,7 +128,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineFunctionEventProperties method', async () => { const serverless = await runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }); const existingEventDefinition = serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ @@ -149,7 +149,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineFunctionEventProperties method on complex event schema', async () => { const serverless = await runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }); const existingEventDefinition = serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ @@ -177,7 +177,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-non-existing-event-error'], }, @@ -189,7 +189,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-complex-event-without-object-definition'], }, @@ -201,7 +201,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-function-event-property'], }, @@ -214,7 +214,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineFunctionProperties method', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { const actualFunctionProperties = serverless.serverless.configSchemaHandler.schema.properties.functions.patternProperties[ @@ -237,7 +237,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-function-property'], }, @@ -250,7 +250,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineCustomProperties method', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { const someCustomStringProp = { type: 'string', @@ -267,7 +267,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-custom-property'], }, @@ -280,7 +280,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineTopLevelProperty method', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { const expectedAppPropSchema = { type: 'string', @@ -296,7 +296,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-top-level-property'], }, @@ -309,7 +309,7 @@ describe('ConfigSchemaHandler', () => { it('should extend schema with defineProvider method', () => { return runServerless({ fixture: 'configSchemaExtensions', - cliArgs: ['info'], + command: 'info', }).then((serverless) => { const providerPieceOfSchema = { type: 'object', @@ -339,7 +339,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-provider-property-in-provider'], }, @@ -351,7 +351,7 @@ describe('ConfigSchemaHandler', () => { await expect( runServerless({ fixture: 'configSchemaExtensionsError', - cliArgs: ['info'], + command: 'info', configExt: { plugins: ['./test-plugin-with-colliding-provider-property-in-function'], }, diff --git a/test/unit/lib/classes/PluginManager.test.js b/test/unit/lib/classes/PluginManager.test.js index a12fa768746..e2bd6d52fe6 100644 --- a/test/unit/lib/classes/PluginManager.test.js +++ b/test/unit/lib/classes/PluginManager.test.js @@ -21,11 +21,9 @@ const mockRequire = require('mock-require'); const sinon = require('sinon'); const proxyquire = require('proxyquire'); const BbPromise = require('bluebird'); -const stripAnsi = require('strip-ansi'); const getCacheFilePath = require('../../../../lib/utils/getCacheFilePath'); const { installPlugin } = require('../../../utils/plugins'); const { getTmpDirPath } = require('../../../utils/fs'); -const runServerless = require('../../../utils/run-serverless'); chai.use(require('chai-as-promised')); chai.use(require('sinon-chai')); @@ -2056,11 +2054,3 @@ describe('PluginManager', () => { }); }); }); - -describe('test/unit/lib/classes/PluginManager.test.js', () => { - it('should show help when running container command', async () => { - // Note: Arbitrarily picked "plugin" command for testing - const { stdoutData } = await runServerless({ fixture: 'aws', cliArgs: ['plugin'] }); - expect(stripAnsi(stdoutData)).to.include('plugin install .......'); - }); -}); diff --git a/test/unit/lib/classes/Service.test.js b/test/unit/lib/classes/Service.test.js index 9b500b3fee6..0fc5cb155a8 100644 --- a/test/unit/lib/classes/Service.test.js +++ b/test/unit/lib/classes/Service.test.js @@ -13,47 +13,47 @@ describe('Service', () => { it('should reject when the service name is missing', () => expect( runServerless({ - fixture: 'configInvalid', - cliArgs: ['print'], + fixture: 'blank', + command: 'print', }) ).to.eventually.be.rejected.and.have.property('code', 'SERVICE_NAME_MISSING')); it('should reject if provider property is missing', () => expect( runServerless({ - fixture: 'configInvalid', + fixture: 'blank', configExt: { service: 'foo' }, - cliArgs: ['print'], + command: 'print', }) ).to.eventually.be.rejected.and.have.property('code', 'PROVIDER_NAME_MISSING')); it('should reject if frameworkVersion is not satisfied', () => expect( runServerless({ - fixture: 'configTypeYml', + fixture: 'aws', configExt: { frameworkVersion: '1.0' }, - cliArgs: ['print'], + command: 'print', }) ).to.eventually.be.rejected.and.have.property('code', 'FRAMEWORK_VERSION_MISMATCH')); it('should pass if frameworkVersion is satisfied', () => runServerless({ - fixture: 'configTypeYml', + fixture: 'aws', configExt: { frameworkVersion: version }, - cliArgs: ['print'], + command: 'print', }) .then(() => runServerless({ - fixture: 'configTypeYml', + fixture: 'aws', configExt: { frameworkVersion: '*' }, - cliArgs: ['print'], + command: 'print', }) ) .then(() => runServerless({ - fixture: 'configTypeYml', + fixture: 'aws', configExt: { frameworkVersion: version.split('.')[0] }, - cliArgs: ['print'], + command: 'print', }) )); }); @@ -80,7 +80,7 @@ describe('Service', () => { }, ], }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate: { Resources } }) => { expect(Resources).to.be.an('object'); expect(Resources.resource1).to.deep.equal({ Type: 'value' }); @@ -89,7 +89,7 @@ describe('Service', () => { it('should merge functions given as an array', () => runServerless({ - fixture: 'configTypeYml', + fixture: 'aws', configExt: { functions: [ { @@ -100,7 +100,7 @@ describe('Service', () => { }, ], }, - cliArgs: ['print'], + command: 'print', }).then( ({ serverless: { @@ -118,7 +118,7 @@ describe('Service', () => { it('should make sure function name contains the default stage', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', }); expect( cfTemplate.Resources[awsNaming.getLambdaLogicalId('foo')].Properties.FunctionName @@ -129,7 +129,7 @@ describe('Service', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { bar: null, diff --git a/test/unit/lib/classes/Variables.test.js b/test/unit/lib/classes/Variables.test.js index d31066f5de6..d6bc95ec978 100644 --- a/test/unit/lib/classes/Variables.test.js +++ b/test/unit/lib/classes/Variables.test.js @@ -2762,7 +2762,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { before(async () => { const result = await runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', shouldUseLegacyVariablesResolver: true, }); processedConfig = result.serverless.service; @@ -2827,7 +2827,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { await expect( runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { unresolvedVariablesNotificationMode: 'error', custom: { myVariable: '${env:missingEnvVar}' }, @@ -2841,7 +2841,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { await expect( runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { unresolvedVariablesNotificationMode: 'error', custom: { myVariable: '${opt:missingOpt}' }, @@ -2855,7 +2855,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { await expect( runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { unresolvedVariablesNotificationMode: 'error', custom: { myVariable: '${self:missingAttribute}' }, @@ -2869,7 +2869,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { await expect( runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { unresolvedVariablesNotificationMode: 'error', custom: { myVariable: '${file(./missingFile)}' }, @@ -2884,7 +2884,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { it('prints warnings to the console but no deprecation message', async () => { const { serverless, stdoutData } = await runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { unresolvedVariablesNotificationMode: 'warn', custom: { @@ -2913,7 +2913,7 @@ describe('test/unit/lib/classes/Variables.test.js', () => { it('should warn and print a deprecation message', async () => { const { serverless } = await runServerless({ fixture: 'variables-legacy', - cliArgs: ['print'], + command: 'print', configExt: { custom: { myVariable1: '${env:missingEnvVar}', diff --git a/test/unit/lib/configSchema.test.js b/test/unit/lib/configSchema.test.js index 38897e05516..7fd86a8e065 100644 --- a/test/unit/lib/configSchema.test.js +++ b/test/unit/lib/configSchema.test.js @@ -122,7 +122,7 @@ describe('#configSchema', () => { runServerless({ fixture: 'configSchemaExtensions', configExt: someCase.mutation, - cliArgs: ['info'], + command: 'info', }).then( ({ stdoutData }) => { if (!someCase.isValid) { diff --git a/test/unit/lib/plugins/aws/customResources/index.test.js b/test/unit/lib/plugins/aws/customResources/index.test.js index 35950599e38..68775f98732 100644 --- a/test/unit/lib/plugins/aws/customResources/index.test.js +++ b/test/unit/lib/plugins/aws/customResources/index.test.js @@ -208,7 +208,7 @@ describe('#addCustomResourceToService()', () => { const role = 'arn:aws:iam::999999999999:role/my-role'; const { cfTemplate } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { cfnRole: role, @@ -360,7 +360,8 @@ describe('test/unit/lib/plugins/aws/customResources/index.test.js', () => { it('correctly takes stage from cli into account when constructing apiGatewayCloudWatchRole resource', async () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', - cliArgs: ['package', '--stage', 'testing'], + command: 'package', + options: { stage: 'testing' }, configExt: { provider: { logs: { @@ -378,7 +379,7 @@ describe('test/unit/lib/plugins/aws/customResources/index.test.js', () => { it('correctly takes stage from config into account when constructing apiGatewayCloudWatchRole resource', async () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', - cliArgs: ['package'], + command: 'package', configExt: { provider: { stage: 'testing', diff --git a/test/unit/lib/plugins/aws/deploy/index.test.js b/test/unit/lib/plugins/aws/deploy/index.test.js index 729f3ea3185..7e127fd4744 100644 --- a/test/unit/lib/plugins/aws/deploy/index.test.js +++ b/test/unit/lib/plugins/aws/deploy/index.test.js @@ -282,7 +282,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy'], + command: 'deploy', awsRequestStubMap, }); @@ -360,7 +360,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy'], + command: 'deploy', awsRequestStubMap, configExt: { // Default, non-deterministic service-name invalidates this test as S3 Bucket cleanup relies on it @@ -470,7 +470,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => { const { serverless } = await runServerless({ fixture: 'packageArtifactInServerlessDir', - cliArgs: ['deploy'], + command: 'deploy', awsRequestStubMap, configExt: { // Default, non-deterministic service-name invalidates this test diff --git a/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js b/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js index d1db3f2d1fe..15072c2588e 100644 --- a/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js +++ b/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js @@ -577,7 +577,7 @@ describe('checkForChanges #2', () => { it('Should recognize package.artifact', () => runServerless({ fixture: 'packageArtifact', - cliArgs: ['deploy'], + command: 'deploy', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', awsRequestStubMap: { @@ -695,7 +695,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -731,7 +731,8 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy', '--force'], + command: 'deploy', + options: { force: true }, lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -761,7 +762,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { const { serverless } = await runServerless({ fixture: 'packageFoldern', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, awsRequestStubMap: { @@ -787,7 +788,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -818,7 +819,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -848,7 +849,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { fixtureData: { updateConfig, servicePath }, } = await runServerless({ fixture: 'checkForChanges', - cliArgs: ['package'], + command: 'package', }); const listObjectsV2Response = await generateMatchingListObjectsResponse(serverless); @@ -857,7 +858,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -886,7 +887,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, hooks: { @@ -915,7 +916,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { package: { individually: true }, }, @@ -948,7 +949,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { package: { individually: true }, }, @@ -982,7 +983,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { package: { artifact: 'artifact.zip' }, }, @@ -1013,7 +1014,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { const { serverless } = await runServerless({ fixture: 'packageArtifactInServerlessDir', - cliArgs: ['deploy'], + command: 'deploy', configExt: { // runServerless by default makes this: `test-${fixtureName}-${TIME_BASED_HASH}` // for safety of concurrent test runs. Unfortunately this will make our @@ -1088,7 +1089,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { it('should print a warning if missing lambda:GetFunction permission', async () => { const { stdoutData } = await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', awsRequestStubMap: { ...commonAwsSdkMock, @@ -1115,7 +1116,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { return expect( runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, awsRequestStubMap: { @@ -1139,7 +1140,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { return expect( runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:checkForChanges', env: { AWS_CONTAINER_CREDENTIALS_FULL_URI: 'ignore' }, awsRequestStubMap: { @@ -1162,7 +1163,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { functions: { fn1: { events: [{ cloudwatchLog: 'someLogGroupName' }] } }, }, @@ -1210,7 +1211,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { functions: { fn1: { events: [{ cloudwatchLog: 'someLogGroupName' }] } }, }, @@ -1258,7 +1259,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; const { awsNaming } = await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { functions: { fn1: { @@ -1339,7 +1340,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js', () => { let serverless; await runServerless({ fixture: 'checkForChanges', - cliArgs: ['deploy'], + command: 'deploy', configExt: { functions: { fn1: { events: [{ cloudwatchLog: 'someLogGroupName' }] } }, }, diff --git a/test/unit/lib/plugins/aws/deploy/lib/createStack.test.js b/test/unit/lib/plugins/aws/deploy/lib/createStack.test.js index cf01d5389fe..f7afc2e03bf 100644 --- a/test/unit/lib/plugins/aws/deploy/lib/createStack.test.js +++ b/test/unit/lib/plugins/aws/deploy/lib/createStack.test.js @@ -258,7 +258,7 @@ describe('createStack #2', () => { it('should use iam.deploymentRole service role if set', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy'], + command: 'deploy', configExt: { provider: { iam: { @@ -279,7 +279,7 @@ describe('createStack #2', () => { it('should use CloudFormation service role ARN if it is specified', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy'], + command: 'deploy', configExt: { provider: { cfnRole: 'arn:aws:iam::123456789012:role/role-b', diff --git a/test/unit/lib/plugins/aws/deploy/lib/extendedValidate.test.js b/test/unit/lib/plugins/aws/deploy/lib/extendedValidate.test.js index 1ca0ef0f7af..296bc0ab396 100644 --- a/test/unit/lib/plugins/aws/deploy/lib/extendedValidate.test.js +++ b/test/unit/lib/plugins/aws/deploy/lib/extendedValidate.test.js @@ -217,7 +217,7 @@ describe('test/unit/lib/plugins/aws/deploy/lib/extendedValidate.test.js', () => }, }, }, - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'before:deploy:deploy', }); diff --git a/test/unit/lib/plugins/aws/deployFunction.test.js b/test/unit/lib/plugins/aws/deployFunction.test.js index c7ae5dc788d..04a47af4d98 100644 --- a/test/unit/lib/plugins/aws/deployFunction.test.js +++ b/test/unit/lib/plugins/aws/deployFunction.test.js @@ -355,7 +355,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should support deploying function that has image defined with sha', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap, configExt: { functions: { @@ -372,7 +373,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should support updating function with image config', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap, configExt: { functions: { @@ -400,7 +402,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should skip updating function configuration if image config did not change', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -443,7 +446,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should skip deployment if image sha did not change', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -472,7 +476,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -503,7 +508,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -532,7 +538,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { .resolves({}); const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -559,7 +566,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should update function configuration if configuration changed', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -630,7 +638,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should skip updating properties that contain references', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -678,7 +687,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should update function configuration with provider-level properties', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -736,7 +746,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('should not update function configuration if configuration did not change', async () => { const { stdoutData } = await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap: { ...awsRequestStubMap, Lambda: { @@ -809,7 +820,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('configuration uses the "kmsKeyArn" instead of functionObj.awsKmsKeyArn', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap, configExt: { @@ -836,7 +848,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('configuration uses the "kmsKeyArn" instead of serviceObj.awsKmsKeyArn', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap, configExt: { @@ -864,7 +877,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('configuration uses serviceObj.awsKmsKeyArn if no kmsKeyArn provided', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap, configExt: { @@ -891,7 +905,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { it('configuration uses functionObj.awsKmsKeyArn and if kmsKeyArn not provided', async () => { await runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap, configExt: { @@ -916,7 +931,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap: { ...awsRequestStubMap, @@ -935,7 +951,8 @@ describe('test/unit/lib/plugins/aws/deployFunction.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['deploy', 'function', '--function', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, lastLifecycleHookName: 'deploy:function:deploy', awsRequestStubMap: { ...awsRequestStubMap, diff --git a/test/unit/lib/plugins/aws/invoke.test.js b/test/unit/lib/plugins/aws/invoke.test.js index 9089ec55ba5..8195e4acf4b 100644 --- a/test/unit/lib/plugins/aws/invoke.test.js +++ b/test/unit/lib/plugins/aws/invoke.test.js @@ -254,14 +254,12 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { result = await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - '--function', - 'callback', - '--data', - '{"inputKey":"inputValue"}', - '--log', - ], + command: 'invoke', + options: { + function: 'callback', + data: '{"inputKey":"inputValue"}', + log: true, + }, awsRequestStubMap: { Lambda: { invoke: (args) => { @@ -301,7 +299,8 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should accept no data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback'], + command: 'invoke', + options: { function: 'callback' }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -313,7 +312,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support plain string data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--data', 'inputData'], + command: 'invoke', + options: { + function: 'callback', + data: 'inputData', + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -325,7 +328,12 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should should not attempt to parse data with raw option', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--data', '{"inputKey":"inputValue"}', '--raw'], + command: 'invoke', + options: { + function: 'callback', + data: '{"inputKey":"inputValue"}', + raw: true, + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -337,7 +345,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support JSON file path as data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--path', 'payload.json'], + command: 'invoke', + options: { + function: 'callback', + path: 'payload.json', + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -349,12 +361,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support absolute file path as data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - '--function', - 'callback', - '--path' /* TODO: Pass absolute path to payload.json in fixture */, - ], + command: 'invoke', + options: { + function: 'callback', + path: '' /* TODO: Pass absolute path to payload.json in fixture */, + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -366,7 +377,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support YAML file path as data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--path', 'payload.yaml'], + command: 'invoke', + options: { + function: 'callback', + path: 'payload.yaml', + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Payload` param }, @@ -379,7 +394,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--path', 'not-existing.yaml'], + command: 'invoke', + options: { + function: 'callback', + path: 'not-existing.yaml', + }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Replaces @@ -390,7 +409,8 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'notExisting'], + command: 'invoke', + options: { function: 'notExisting' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Replaces @@ -400,7 +420,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support --type option', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--type', 'Event'], + command: 'invoke', + options: { + function: 'callback', + type: 'Event', + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `InvocationType` param }, @@ -412,7 +436,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { xit('TODO: should support --qualifier option', async () => { await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--qualifier', 'foo'], + command: 'invoke', + options: { + function: 'callback', + qualifier: 'foo', + }, awsRequestStubMap: { // Stub AWS SDK invocation, and confirm `Qualifier` param }, @@ -426,7 +454,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { const result = await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--context', 'somecontext'], + command: 'invoke', + options: { + function: 'callback', + context: 'somecontext', + }, awsRequestStubMap: { Lambda: { invoke: (args) => { @@ -451,7 +483,12 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { const result = await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--raw', '--context', '{"ctx": "somecontext"}'], + command: 'invoke', + options: { + function: 'callback', + context: '{"ctx": "somecontext"}', + raw: true, + }, awsRequestStubMap: { Lambda: { invoke: (args) => { @@ -473,20 +510,25 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { it('should support `--contextPath` param', async () => { const lambdaInvokeStub = sinon.stub(); - const contextDataFile = path.join( + const contextDataFilePath = path.join( __dirname, '..', '..', '..', '..', 'fixtures', + 'programmatic', 'invocation', 'context.json' ); const result = await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--contextPath', contextDataFile], + command: 'invoke', + options: { + function: 'callback', + contextPath: contextDataFilePath, + }, awsRequestStubMap: { Lambda: { invoke: (args) => { @@ -509,12 +551,16 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { it('should throw error on invoke with contextPath if file not exists', async () => { const lambdaInvokeStub = sinon.stub(); - const contextDataFile = path.join(getTmpDirPath(), 'context.json'); + const contextDataFilePath = path.join(getTmpDirPath(), 'context.json'); await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--contextPath', contextDataFile], + command: 'invoke', + options: { + function: 'callback', + contextPath: contextDataFilePath, + }, awsRequestStubMap: { Lambda: { invoke: (args) => { @@ -534,7 +580,11 @@ describe('test/unit/lib/plugins/aws/invoke.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--path', 'not-existing.yaml'], + command: 'invoke', + options: { + function: 'callback', + path: 'not-existing.yaml', + }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Replace diff --git a/test/unit/lib/plugins/aws/invokeLocal/index.test.js b/test/unit/lib/plugins/aws/invokeLocal/index.test.js index fe77b9df7e6..a3a906a2336 100644 --- a/test/unit/lib/plugins/aws/invokeLocal/index.test.js +++ b/test/unit/lib/plugins/aws/invokeLocal/index.test.js @@ -1282,14 +1282,18 @@ describe('AwsInvokeLocal', () => { }); describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { - const testRuntime = (functionName, cliParams = []) => { + const testRuntime = (functionName, options = {}) => { describe.skip('Input resolution', () => { // All tested with individual runServerless run it('TODO: should accept no data', async () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', 'local', '--function', functionName, ...cliParams], + command: 'invoke local', + options: { + ...options, + function: functionName, + }, }); // Replaces @@ -1310,15 +1314,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--data', - 'inputData', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + data: 'inputData', + }, }); // Replaces @@ -1330,15 +1331,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--data', - '{"inputKey":"inputValue"}', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + data: '{"inputKey":"inputValue"}', + }, }); }); @@ -1358,16 +1356,13 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--data', - '{"inputKey":"inputValue"}', - '--raw', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + data: '{"inputKey":"inputValue"}', + raw: true, + }, }); }); @@ -1386,15 +1381,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--path', - 'payload.json', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + path: 'payload.json', + }, }); }); // Single runServerless run @@ -1408,15 +1400,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { it('TODO: should support YAML file path as data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--path', - 'payload.yaml', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + path: 'payload.yaml', + }, }); // Replaces @@ -1426,15 +1415,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { it('TODO: should support JS file path for data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--path', - 'payload.js', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + path: 'payload.js', + }, }); // Replaces @@ -1444,14 +1430,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { it('TODO: should support absolute file path as data', async () => { await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--path' /* TODO: Pass absolute path to payload.json in fixture */, - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + path: '' /* TODO: Pass absolute path to payload.json in fixture */, + }, }); // Replaces // https://github.com/serverless/serverless/blob/95c0bc09421b869ae1d8fc5dea42a2fce1c2023e/test/unit/lib/plugins/aws/invokeLocal/index.test.js#L213-L227 @@ -1461,7 +1445,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--path', 'not-existing.yaml'], + command: 'invoke local', + options: { + ...options, + function: functionName, + path: 'not-existing.yaml', + }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Replaces @@ -1472,7 +1461,11 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'notExisting'], + command: 'invoke local', + options: { + ...options, + function: 'notExisting', + }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Replaces @@ -1489,15 +1482,12 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } const response = await runServerless({ fixture: 'invocation', - cliArgs: [ - 'invoke', - 'local', - '--function', - functionName, - ...cliParams, - '--env', - 'PARAM_ENV_VAR=-Dblart=snort', - ], + command: 'invoke local', + options: { + ...options, + function: functionName, + env: 'PARAM_ENV_VAR=-Dblart=snort', + }, configExt: { provider: { environment: { @@ -1568,7 +1558,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'async'], + command: 'invoke local', + options: { function: 'async' }, }); // Replaces @@ -1581,7 +1572,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'contextDone'], + command: 'invoke local', + options: { function: 'contextDone' }, }); // Replaces @@ -1592,14 +1584,16 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'contextSucceed'], + command: 'invoke local', + options: { function: 'contextSucceed' }, }); }); xit('TODO: should support immediate failure at initialization', async () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'initFail'], + command: 'invoke local', + options: { function: 'initFail' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); @@ -1611,7 +1605,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'invocationFail'], + command: 'invoke local', + options: { function: 'invocationFail' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1619,7 +1614,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'async', '--data', '{"shouldFail":true}'], + command: 'invoke local', + options: { function: 'async', data: '{"shouldFail":true}' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); @@ -1633,7 +1629,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'callback', '--data', '{"shouldFail":true}'], + command: 'invoke local', + options: { function: 'callback', data: '{"shouldFail":true}' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); @@ -1644,7 +1641,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'contextDone', '--data', '{"shouldFail":true}'], + command: 'invoke local', + options: { function: 'contextDone', data: '{"shouldFail":true}' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); @@ -1655,7 +1653,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { await expect( runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'contextSucceed', '--data', '{"shouldFail":true}'], + command: 'invoke local', + options: { function: 'contextSucceed', data: '{"shouldFail":true}' }, }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1663,12 +1662,14 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'doubledResolutionCallbackFirst'], + command: 'invoke local', + options: { function: 'doubledResolutionCallbackFirst' }, }); // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'doubledResolutionPromiseFirst'], + command: 'invoke local', + options: { function: 'doubledResolutionPromiseFirst' }, }); // Replaces @@ -1679,7 +1680,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'remainingTime'], + command: 'invoke local', + options: { function: 'remainingTime' }, }); // Replaces @@ -1699,7 +1701,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'pythonRemainingTime'], // TODO: Configure python handler + command: 'invoke local', + options: { function: 'pythonRemainingTime' }, // TODO: Configure python handler }); // Replaces @@ -1718,7 +1721,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'rubyClass'], // TODO: Configure ruby handler + command: 'invoke local', + options: { function: 'rubyClass' }, // TODO: Configure ruby handler }); // Replaces @@ -1729,7 +1733,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'rubyRemainingTime'], // TODO: Configure ruby handler + command: 'invoke local', + options: { function: 'rubyRemainingTime' }, // TODO: Configure ruby handler }); // Replaces @@ -1739,7 +1744,8 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => { // Confirm outcome on { stdout } await runServerless({ fixture: 'invocation', - cliArgs: ['invoke', '--function', 'rubyDeadline'], // TODO: Configure ruby handler + command: 'invoke local', + options: { function: 'rubyDeadline' }, // TODO: Configure ruby handler }); // Replaces diff --git a/test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js index 2a2a427cc4f..fcf3336ae6d 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js @@ -37,7 +37,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js', ( const { awsNaming, cfTemplate } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { alb: { @@ -195,7 +195,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/alb/index.test.js', ( const runServerlessAction = () => runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { fnConditionsHostOnly: { diff --git a/test/unit/lib/plugins/aws/package/compile/events/alb/lib/healthCheck.test.js b/test/unit/lib/plugins/aws/package/compile/events/alb/lib/healthCheck.test.js index 4d73fb0fdff..d3724d670b0 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/alb/lib/healthCheck.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/alb/lib/healthCheck.test.js @@ -119,7 +119,7 @@ describe('ALB TargetGroup Health Checks', () => { runServerless({ fixture: 'function', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate, awsNaming }) => { ({ Resources: cfResources } = cfTemplate); naming = awsNaming; diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/authorizers.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/authorizers.test.js index 03668ecef5b..0ea4d9cfb90 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/authorizers.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/authorizers.test.js @@ -235,7 +235,7 @@ describe('#compileAuthorizers() #2', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { // console.log(cfTemplate.Resources); const authorizerLogicalId = awsNaming.getAuthorizerLogicalId('foo'); diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/hack/updateStage.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/hack/updateStage.test.js index 7f82143ed9f..97c386f52f9 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/hack/updateStage.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/hack/updateStage.test.js @@ -756,7 +756,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/hack/u const untagResourceStub = sinon.stub(); await runServerless({ fixture: 'apiGateway', - cliArgs: ['deploy'], + command: 'deploy', configExt: { provider: { apiName: 'test-api-name', diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js index 137ec053599..9e86c80f60f 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js @@ -497,7 +497,7 @@ describe('#compileMethods()', () => { it('should set required to true when omitted from mapped value', async () => { const { cfTemplate } = await runServerless({ - cliArgs: ['package'], + command: 'package', fixture: 'function', configExt: { functions: { @@ -1763,7 +1763,7 @@ describe('#compileMethods v2()', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); const apiGatewayMethodConfig = cfResources[awsNaming.getMethodLogicalId('Foo', 'GET')]; diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/requestParameters.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/requestParameters.test.js index 196253d3dc4..763e251214b 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/requestParameters.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/method/requestParameters.test.js @@ -60,7 +60,7 @@ describe('ApiGatewayEvents', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate, awsNaming }) => { ({ Resources: cfResources } = cfTemplate); naming = awsNaming; diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.test.js index ccd9c5efbad..daa27b8c54b 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/requestValidator.test.js @@ -13,7 +13,7 @@ describe('#compileRequestValidators()', () => { before(async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'requestSchema', - cliArgs: ['package'], + command: 'package', }); cfResources = cfTemplate.Resources; naming = awsNaming; diff --git a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/usagePlan.test.js b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/usagePlan.test.js index 8a1725f5b2e..b6723aa837f 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/usagePlan.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/apiGateway/lib/usagePlan.test.js @@ -333,7 +333,7 @@ describe('UsagePlan', () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources.ApiGatewayUsagePlan.Properties.Throttle.BurstLimit).to.be.equal( @@ -349,7 +349,7 @@ describe('UsagePlan', () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources.ApiGatewayUsagePlan.Properties.Quota.Limit).to.be.equal(limit); @@ -362,7 +362,7 @@ describe('UsagePlan', () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources.ApiGatewayUsagePlan.Properties.Throttle.BurstLimit).to.be.equal( @@ -380,7 +380,7 @@ describe('UsagePlan', () => { const { cfTemplate } = await runServerless({ fixture: 'apiGateway', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources.ApiGatewayUsagePlan.Properties.Throttle.BurstLimit).to.be.equal( diff --git a/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js b/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js index e112057d369..e0b61a30c29 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js @@ -1638,7 +1638,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // Inspect result.stdoutData await runServerless({ fixture: 'function', - cliArgs: ['remove'], + command: 'remove', lastLifecycleHookName: 'before:remove:remove', }); }); @@ -1650,7 +1650,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // Inspect result.stdoutData await runServerless({ fixture: 'function', - cliArgs: ['remove'], + command: 'remove', lastLifecycleHookName: 'before:remove:remove', }); }); @@ -1662,7 +1662,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L131-L167 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); // Ensure ServerlessError is thrown and that it has some meaningful code // Then test like here: @@ -1674,7 +1674,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L169-L204 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1683,7 +1683,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L206-L242 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1692,7 +1692,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L206-L242 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1701,7 +1701,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L244-L280 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1710,7 +1710,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L244-L280 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1719,7 +1719,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L355-L430 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1728,7 +1728,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L988-L1034 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1737,7 +1737,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L1308-L1369 return expect( - runServerless({ fixture: 'function', cliArgs: ['package'] }) + runServerless({ fixture: 'function', command: 'package' }) ).to.eventually.be.rejected.and.have.property('code', 'TODO'); }); @@ -1745,7 +1745,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', return expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { foo: { @@ -1773,7 +1773,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', return expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { foo: { @@ -1808,7 +1808,7 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', const cachePolicyId = '08627262-05a9-4f76-9ded-b50ca2e3a84f'; await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { foo: { @@ -1840,28 +1840,28 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', // Replaces // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L572-L593 - await runServerless({ fixture: 'function', cliArgs: ['package'] }); + await runServerless({ fixture: 'function', command: 'package' }); }); it('should create DefaultCacheBehavior if there are no events without PathPattern configured', async () => { // Replaces // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L1133-L1197 - await runServerless({ fixture: 'function', cliArgs: ['package'] }); + await runServerless({ fixture: 'function', command: 'package' }); }); it('should throw if more than one origin with the same PathPattern', async () => { // Replaces // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L1519-L1577 - await runServerless({ fixture: 'function', cliArgs: ['package'] }); + await runServerless({ fixture: 'function', command: 'package' }); }); it('should throw if more than one origin with the same event type', async () => { // Replaces // https://github.com/serverless/serverless/blob/85e480b5771d5deeb45ae5eb586723c26cf61a90/lib/plugins/aws/package/compile/events/cloudFront/index.test.js#L1579-L1640 - await runServerless({ fixture: 'function', cliArgs: ['package'] }); + await runServerless({ fixture: 'function', command: 'package' }); }); }); @@ -1909,7 +1909,8 @@ describe('lib/plugins/aws/package/compile/events/cloudFront/index.new.test.js', }, } = await runServerless({ fixture: 'function', - cliArgs: ['package', '--stage', stage], + command: 'package', + options: { stage }, configExt: { provider: { cloudFront: { diff --git a/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js index 792c68e7450..692e6f1e8b7 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/eventBridge/index.test.js @@ -139,7 +139,7 @@ describe('EventBridgeEvents', () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', configExt: serverlessConfigurationExtension, - cliArgs: ['package'], + command: 'package', }); cfResources = cfTemplate.Resources; naming = awsNaming; @@ -252,7 +252,7 @@ describe('EventBridgeEvents', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.be.eventually.rejected.and.have.property( 'code', @@ -329,7 +329,7 @@ describe('EventBridgeEvents', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); cfResources = cfTemplate.Resources; naming = awsNaming; @@ -405,7 +405,7 @@ describe('EventBridgeEvents', () => { before(async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { eventBridge: { diff --git a/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js b/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js index 38c07ae2961..b5e075045ed 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/httpApi.test.js @@ -11,7 +11,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { it('should not configure HTTP API resources when no events are configured', () => runServerless({ config: { service: 'irrelevant', provider: 'aws' }, - cliArgs: ['package'], + command: 'package', }).then(({ serverless }) => { const cfResources = serverless.service.provider.compiledCloudFormationTemplate.Resources; const naming = serverless.getProvider('aws').naming; @@ -28,7 +28,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { before(() => runServerless({ fixture: 'httpApi', - cliArgs: ['package'], + command: 'package', configExt: { functions: { catchAll: { handler: 'index.handler', events: [{ httpApi: '*' }] }, @@ -183,7 +183,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate, fixtureData }) => { const { Resources } = cfTemplate; cfApi = Resources[awsNaming.getHttpApiLogicalId()]; @@ -267,7 +267,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { cfCors = cfTemplate.Resources[awsNaming.getHttpApiLogicalId()].Properties.CorsConfiguration; @@ -309,7 +309,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { cfCors = cfTemplate.Resources[awsNaming.getHttpApiLogicalId()].Properties.CorsConfiguration; @@ -337,7 +337,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { cfCors = cfTemplate.Resources[awsNaming.getHttpApiLogicalId()].Properties.CorsConfiguration; @@ -410,7 +410,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); cfResources = cfTemplate.Resources; naming = awsNaming; @@ -565,7 +565,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -603,7 +603,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -640,7 +640,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -678,7 +678,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -705,7 +705,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -747,7 +747,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { cfResources = cfTemplate.Resources; naming = awsNaming; @@ -797,7 +797,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -825,7 +825,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); const routeResourceProps = cfTemplate.Resources[awsNaming.getHttpApiRouteLogicalId('GET /foo')].Properties; @@ -853,7 +853,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -898,7 +898,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); cfResources = cfTemplate.Resources; naming = awsNaming; @@ -943,7 +943,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -964,7 +964,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { runServerless({ fixture: 'httpApi', configExt: { provider: { httpApi: { id: apiId } } }, - cliArgs: ['package'], + command: 'package', }).then(({ awsNaming, cfTemplate }) => { ({ Resources: cfResources, Outputs: cfOutputs } = cfTemplate); naming = awsNaming; @@ -1013,7 +1013,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property('code', 'EXTERNAL_HTTP_API_CORS_CONFIG'); }); @@ -1035,7 +1035,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', @@ -1056,7 +1056,7 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property('code', 'EXTERNAL_HTTP_API_LOGS_CONFIG'); }); diff --git a/test/unit/lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test.js index 15e078278f0..f81d67876b0 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test.js @@ -2,7 +2,7 @@ const chai = require('chai'); const runServerless = require('../../../../../../../../utils/run-serverless'); -const templateBody = require('../../../../../../../../fixtures/iotFleetProvisioning/template.json'); +const templateBody = require('../../../../../../../../fixtures/programmatic/iotFleetProvisioning/template.json'); chai.use(require('chai-as-promised')); @@ -64,7 +64,7 @@ describe('lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test }, }, }, - cliArgs: ['package'], + command: 'package', }); ({ Resources: cfResources } = cfTemplate); serviceName = serviceConfig.service; @@ -148,7 +148,7 @@ describe('lib/plugins/aws/package/compile/events/iotFleetProvisioning/index.test }, }, }, - cliArgs: ['package'], + command: 'package', }) ).to.eventually.be.rejected.and.have.property( 'code', diff --git a/test/unit/lib/plugins/aws/package/compile/events/kafka.test.js b/test/unit/lib/plugins/aws/package/compile/events/kafka.test.js index 475177b263e..16964878d7d 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/kafka.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/kafka.test.js @@ -53,7 +53,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => }, }, }, - cliArgs: ['package'], + command: 'package', }); naming = awsNaming; minimalEventSourceMappingResource = @@ -136,7 +136,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => }, }, }, - cliArgs: ['package'], + command: 'package', }); const eventSourceMappingResource = @@ -358,7 +358,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => }, }, }, - cliArgs: ['package'], + command: 'package', }); const defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution; expect(defaultIamRole.Properties.Policies[0].PolicyDocument.Statement).to.deep.include({ @@ -394,7 +394,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => }, }, }, - cliArgs: ['package'], + command: 'package', }); const eventSourceMappingResource = @@ -407,7 +407,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => it('should not modify the default IAM role', async () => { const { cfTemplate } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', }); const defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution; diff --git a/test/unit/lib/plugins/aws/package/compile/events/msk/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/msk/index.test.js index 9cae695d93d..e95b9307466 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/msk/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/msk/index.test.js @@ -50,7 +50,7 @@ describe('AwsCompileMSKEvents', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); naming = awsNaming; minimalEventSourceMappingResource = @@ -117,7 +117,7 @@ describe('AwsCompileMSKEvents', () => { it('should not modify the default IAM role', async () => { const { cfTemplate } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', }); const defaultIamRole = cfTemplate.Resources.IamRoleLambdaExecution; diff --git a/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js index baf3621c934..a032d87385b 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/s3/index.test.js @@ -837,8 +837,23 @@ describe('AwsCompileS3Events', () => { it('should create lambda permissions policy with wild card', async () => { const { cfTemplate } = await runServerless({ - fixture: 's3', - cliArgs: ['package'], + fixture: 'function', + configExt: { + functions: { + foo: { + events: [ + { + s3: { + bucket: 'foo', + event: 's3:ObjectCreated:*', + existing: true, + }, + }, + ], + }, + }, + }, + command: 'package', }); const expectedResource = [ diff --git a/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js b/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js index 5b4fbda7221..3124cc0302c 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/sqs.test.js @@ -609,7 +609,7 @@ describe('AwsCompileSQSEvents #2', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); naming = awsNaming; const queueLogicalId = awsNaming.getQueueLogicalId('foo', 'MyQueue'); diff --git a/test/unit/lib/plugins/aws/package/compile/events/stream.test.js b/test/unit/lib/plugins/aws/package/compile/events/stream.test.js index ab6c5440527..af2404dd754 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/stream.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/stream.test.js @@ -1598,7 +1598,7 @@ describe('AwsCompileStreamEvents #2', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); naming = awsNaming; const streamLogicalId = awsNaming.getStreamLogicalId('foo', 'kinesis', 'myStream'); @@ -1644,7 +1644,7 @@ describe('AwsCompileStreamEvents #2', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); const streamLogicalId = awsNaming.getStreamLogicalId('foo', 'kinesis', 'myStream'); eventSourceMappingResource = cfTemplate.Resources[streamLogicalId]; diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/validate.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/validate.test.js index 635b557240b..07af507669f 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/validate.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/validate.test.js @@ -294,7 +294,7 @@ describe('#validate() using runServerless util', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); const cfResources = cfTemplate.Resources; diff --git a/test/unit/lib/plugins/aws/package/compile/functions.test.js b/test/unit/lib/plugins/aws/package/compile/functions.test.js index 51de63d0e4c..88bd132f40a 100644 --- a/test/unit/lib/plugins/aws/package/compile/functions.test.js +++ b/test/unit/lib/plugins/aws/package/compile/functions.test.js @@ -10,7 +10,7 @@ const AwsProvider = require('../../../../../../../lib/plugins/aws/provider'); const AwsCompileFunctions = require('../../../../../../../lib/plugins/aws/package/compile/functions'); const Serverless = require('../../../../../../../lib/Serverless'); const runServerless = require('../../../../../../utils/run-serverless'); -const fixtures = require('../../../../../../fixtures'); +const fixtures = require('../../../../../../fixtures/programmatic'); const getHashForFilePath = require('../../../../../../../lib/plugins/aws/package/lib/getHashForFilePath'); const { getTmpDirPath, createTmpFile } = require('../../../../../../utils/fs'); @@ -241,7 +241,7 @@ describe('AwsCompileFunctions', () => { iam: { role: 'role-b' }, }, }, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources.FooLambdaFunction.Properties.Role).to.eql({ @@ -1467,7 +1467,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { before(async () => { const { awsNaming, cfTemplate, fixtureData } = await runServerless({ fixture: 'packageArtifact', - cliArgs: ['package'], + command: 'package', configExt: { service: { // TODO: When removing support for service.awsKmsKeyArn, whole service object @@ -1745,7 +1745,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { before(async () => { const { awsNaming, cfTemplate, fixtureData } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iam: { @@ -1780,7 +1780,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { it('should support `provider.iam.role` defined as CF function', async () => { const { awsNaming, cfTemplate, fixtureData } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iam: { @@ -1804,7 +1804,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { // https://github.com/serverless/serverless/blob/d8527d8b57e7e5f0b94ba704d9f53adb34298d99/lib/plugins/aws/package/compile/functions/index.test.js#L2222-L2286 it('should support resource name', async () => { - await runServerless({ fixture: 'function', configExt: {} }); + await runServerless({ fixture: 'function', configExt: {}, command: 'package' }); // Replacement for // https://github.com/serverless/serverless/blob/d8527d8b57e7e5f0b94ba704d9f53adb34298d99/lib/plugins/aws/package/compile/functions/index.test.js#L235-L257 // @@ -1813,7 +1813,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { }); it('should support Fn::GetAtt function', async () => { - await runServerless({ fixture: 'function', configExt: {} }); + await runServerless({ fixture: 'function', configExt: {}, command: 'package' }); // Replacement for // https://github.com/serverless/serverless/blob/d8527d8b57e7e5f0b94ba704d9f53adb34298d99/lib/plugins/aws/package/compile/functions/index.test.js#L259-L281 // @@ -1834,7 +1834,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const { cfTemplate: originalTemplate, awsNaming } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', }); const functionCfLogicalId = awsNaming.getLambdaLogicalId('foo'); @@ -1852,7 +1852,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { }); const { cfTemplate: updatedTemplate } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', }); const updatedVersionCfConfig = Object.values(updatedTemplate.Resources).find( (resource) => @@ -1881,7 +1881,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { fixtureData, } = await runServerless({ fixture: 'functionDestinations', - cliArgs: ['package'], + command: 'package', configExt: { functions: { fnTargetFailure: { @@ -2108,7 +2108,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { await expect( runServerless({ fixture: 'functionDestinations', - cliArgs: ['package'], + command: 'package', configExt: { functions: { fnInvalidLayer: { @@ -2289,7 +2289,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).catch((error) => { expect(error).to.have.property('code', 'LAMBDA_FILE_SYSTEM_CONFIG_MISSING_VPC'); }); @@ -2312,7 +2312,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const { cfTemplate: originalTemplate } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', }); const originalVersionArn = originalTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref; @@ -2328,7 +2328,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { }); const { cfTemplate: updatedTemplate } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', }); const updatedVersionArn = updatedTemplate.Outputs.FooLambdaFunctionQualifiedArn.Value.Ref; @@ -2354,7 +2354,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { ({ servicePath, updateConfig } = serviceData); const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); firstCfTemplate = data.cfTemplate; @@ -2376,7 +2376,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2395,7 +2395,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2419,7 +2419,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2440,7 +2440,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2455,7 +2455,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2479,7 +2479,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2514,7 +2514,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { const data = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockDescribeStackResponse, }); @@ -2538,7 +2538,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { before(async () => { await runServerless({ fixture: 'packageArtifact', - cliArgs: ['deploy'], + command: 'deploy', configExt: { package: { artifact: 'some s3 url' }, functions: { foo: { package: { individually: true, artifact: 'other s3 url' } } }, @@ -2558,7 +2558,7 @@ describe('lib/plugins/aws/package/compile/functions/index.test.js', () => { // On which we would confirm that // - It's generated string that's being send // - Corresponding url is configured in CF template - // Test with ["deploy"] cliArgs, and configure `lastLifecycleHookName` to 'aws:deploy:deploy:uploadArtifact' + // Test with "deploy" command, and configure `lastLifecycleHookName` to 'aws:deploy:deploy:uploadArtifact' // It'll demand stubbing few other AWS calls for that follow this stub: // https://github.com/serverless/enterprise-plugin/blob/cdd53df45dfad18d8bdd79969194a61cb8178671/lib/deployment/parse.test.js#L1585-L1627 // Confirm same artifact is used for all functions diff --git a/test/unit/lib/plugins/aws/package/compile/layers.test.js b/test/unit/lib/plugins/aws/package/compile/layers.test.js index 8fbff4815de..e0ae6a448f3 100644 --- a/test/unit/lib/plugins/aws/package/compile/layers.test.js +++ b/test/unit/lib/plugins/aws/package/compile/layers.test.js @@ -35,7 +35,7 @@ describe('lib/plugins/aws/package/compile/layers/index.test.js', () => { before(async () => { const { awsNaming, cfTemplate, fixtureData, serverless } = await runServerless({ fixture: 'layer', - cliArgs: ['package'], + command: 'package', configExt: { package: { individually: true, @@ -129,7 +129,7 @@ describe('lib/plugins/aws/package/compile/layers/index.test.js', () => { cfTemplate: { Resources: secondCfResources }, } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap, }); expect(secondCfResources).to.not.have.property(firstLayerResourceName); @@ -139,7 +139,7 @@ describe('lib/plugins/aws/package/compile/layers/index.test.js', () => { cfTemplate: { Resources: firstCfResources }, } = await runServerless({ cwd: servicePath, - cliArgs: ['package'], + command: 'package', awsRequestStubMap, }); expect(firstCfResources).to.have.property(firstLayerResourceName); diff --git a/test/unit/lib/plugins/aws/package/lib/generateCoreTemplate.test.js b/test/unit/lib/plugins/aws/package/lib/generateCoreTemplate.test.js index c1383285d34..5c228204ad9 100644 --- a/test/unit/lib/plugins/aws/package/lib/generateCoreTemplate.test.js +++ b/test/unit/lib/plugins/aws/package/lib/generateCoreTemplate.test.js @@ -10,7 +10,7 @@ describe('#generateCoreTemplate()', () => { it('should reject non-HTTPS requests to the deployment bucket', () => runServerless({ config: { service: 'irrelevant', provider: 'aws' }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate }) => { const serverlessDeploymentBucketPolicy = cfTemplate.Resources.ServerlessDeploymentBucketPolicy; @@ -63,7 +63,7 @@ describe('#generateCoreTemplate()', () => { service: 'irrelevant', provider: { name: 'aws', deploymentBucket: bucketName }, }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate }) => { const template = cfTemplate; expect(template.Outputs.ServerlessDeploymentBucketName.Value).to.equal(bucketName); @@ -83,7 +83,7 @@ describe('#generateCoreTemplate()', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate }) => { expect(cfTemplate.Resources.ServerlessDeploymentBucket.Properties).to.deep.include({ PublicAccessBlockConfiguration: { @@ -109,7 +109,7 @@ describe('#generateCoreTemplate()', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate }) => { expect(cfTemplate.Resources.ServerlessDeploymentBucket).to.be.deep.equal({ Type: 'AWS::S3::Bucket', @@ -142,7 +142,10 @@ describe('#generateCoreTemplate()', () => { deploymentBucket: bucketName, }, }, - cliArgs: ['package', '--aws-s3-accelerate'], + command: 'deploy', + options: { 'aws-s3-accelerate': true }, + lastLifecycleHookName: 'before:deploy:deploy', + awsRequestStubMap: { S3: { getBucketLocation: { LocationConstraint: '' } } }, }).then(({ cfTemplate: template }) => { expect(template.Outputs.ServerlessDeploymentBucketName.Value).to.equal(bucketName); // eslint-disable-next-line no-unused-expressions @@ -155,7 +158,7 @@ describe('#generateCoreTemplate()', () => { it('should use a auto generated bucket if you does not specify deploymentBucket', () => runServerless({ config: { service: 'irrelevant', provider: 'aws' }, - cliArgs: ['package'], + command: 'package', }).then(({ cfTemplate }) => { expect(cfTemplate.Resources.ServerlessDeploymentBucket).to.be.deep.equal({ Type: 'AWS::S3::Bucket', @@ -176,7 +179,9 @@ describe('#generateCoreTemplate()', () => { it('should add a custom output if S3 Transfer Acceleration is enabled', () => runServerless({ config: { service: 'irrelevant', provider: 'aws' }, - cliArgs: ['package', '--aws-s3-accelerate'], + command: 'deploy', + options: { 'aws-s3-accelerate': true }, + lastLifecycleHookName: 'before:deploy:deploy', }).then(({ cfTemplate: template }) => { expect(template.Outputs.ServerlessDeploymentBucketAccelerated).to.not.equal(null); expect(template.Outputs.ServerlessDeploymentBucketAccelerated.Value).to.equal(true); @@ -185,7 +190,9 @@ describe('#generateCoreTemplate()', () => { it('should explicitly disable S3 Transfer Acceleration, if requested', () => runServerless({ config: { service: 'irrelevant', provider: 'aws' }, - cliArgs: ['package', '--no-aws-s3-accelerate'], + command: 'deploy', + options: { 'aws-s3-accelerate': false }, + lastLifecycleHookName: 'before:deploy:deploy', }).then(({ cfTemplate: template }) => { expect(template.Resources.ServerlessDeploymentBucket).to.be.deep.equal({ Type: 'AWS::S3::Bucket', @@ -209,7 +216,9 @@ describe('#generateCoreTemplate()', () => { it('should exclude AccelerateConfiguration for govcloud region', () => runServerless({ config: { service: 'irrelevant', provider: { name: 'aws', region: 'us-gov-west-1' } }, - cliArgs: ['package', '--no-aws-s3-accelerate'], + command: 'deploy', + options: { 'aws-s3-accelerate': false }, + lastLifecycleHookName: 'before:deploy:deploy', }).then(({ cfTemplate: template }) => { expect(template.Resources.ServerlessDeploymentBucket).to.be.deep.equal({ Type: 'AWS::S3::Bucket', @@ -238,7 +247,7 @@ describe('#generateCoreTemplate()', () => { }, }, }, - cliArgs: ['package'], + command: 'package', }); expect(cfTemplate.Resources).to.not.have.property( diff --git a/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js b/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js index 91006572c81..b58e61d1397 100644 --- a/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js +++ b/test/unit/lib/plugins/aws/package/lib/mergeIamTemplates.test.js @@ -8,7 +8,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { it('should not create role resource if there are no functions', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'aws', - cliArgs: ['package'], + command: 'package', }); const iamRoleLambdaExecution = awsNaming.getRoleLogicalId(); expect(cfTemplate.Resources).to.not.have.property(iamRoleLambdaExecution); @@ -17,7 +17,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { it('should not create role resource with `provider.role`', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { name: 'aws', @@ -33,7 +33,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { it('should not create role resource with `provider.iam.role`', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { name: 'aws', @@ -51,7 +51,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { it('should not create role resource with all functions having `functions[].role`', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { foo: { @@ -79,7 +79,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { before(async () => { const test = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { myFunction: { @@ -173,7 +173,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { before(async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iamRoleStatements: [ @@ -245,7 +245,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { before(async () => { const { cfTemplate, awsNaming, fixtureData } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iam: { @@ -286,7 +286,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { const customRoleName = 'custom-default-role'; const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iam: { @@ -370,7 +370,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { it('should not create default role when `provider.iam.role` defined with CF intrinsic functions', async () => { const { cfTemplate, awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { iam: { @@ -394,7 +394,7 @@ describe('lib/plugins/aws/package/lib/mergeIamTemplates.test.js', () => { before(async () => { const { awsNaming, cfTemplate, serverless: serverlessInstance } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { fnDisableLogs: { diff --git a/test/unit/lib/plugins/aws/package/lib/stripNullPropsFromTemplateResources.test.js b/test/unit/lib/plugins/aws/package/lib/stripNullPropsFromTemplateResources.test.js index 621694bf069..dfd3bcdcbba 100644 --- a/test/unit/lib/plugins/aws/package/lib/stripNullPropsFromTemplateResources.test.js +++ b/test/unit/lib/plugins/aws/package/lib/stripNullPropsFromTemplateResources.test.js @@ -11,7 +11,7 @@ describe('test/unit/lib/plugins/aws/package/lib/stripNullPropsFromTemplateResour before(async () => { const result = await runServerless({ fixture: 'aws', - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'package:finalize', configExt: { resources: { diff --git a/test/unit/lib/plugins/aws/provider.test.js b/test/unit/lib/plugins/aws/provider.test.js index 65975d1cc3b..e82945f8372 100644 --- a/test/unit/lib/plugins/aws/provider.test.js +++ b/test/unit/lib/plugins/aws/provider.test.js @@ -694,7 +694,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should default to "us-east-1"', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v'], + command: 'print', }); expect(serverless.getProvider('aws').getRegion()).to.equal('us-east-1'); }); @@ -702,7 +702,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should allow to override via `provider.region`', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v'], + command: 'print', configExt: { provider: { region: 'eu-central-1', @@ -715,7 +715,8 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should allow to override via CLI `--region` param', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v', '--region', 'us-west-1'], + command: 'print', + options: { region: 'us-west-1' }, configExt: { provider: { region: 'eu-central-1', @@ -730,7 +731,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should default to "dev"', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v'], + command: 'print', }); expect(serverless.getProvider('aws').getStage()).to.equal('dev'); }); @@ -738,7 +739,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should allow to override via `provider.stage`', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v'], + command: 'print', configExt: { provider: { stage: 'staging', @@ -751,7 +752,8 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { it('should allow to override via CLI `--stage` param', async () => { const { serverless } = await runServerless({ fixture: 'aws', - cliArgs: ['-v', '--stage', 'production'], + command: 'print', + options: { stage: 'production' }, configExt: { provider: { stage: 'staging', @@ -767,7 +769,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { ecr: { @@ -797,7 +799,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { ecr: { @@ -823,7 +825,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', shouldStubSpawn: true, configExt: { provider: { @@ -844,7 +846,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { functions: { fnInvalid: { @@ -863,7 +865,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', shouldStubSpawn: true, configExt: { functions: { @@ -887,7 +889,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', shouldStubSpawn: true, configExt: { functions: { @@ -930,7 +932,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { before(async () => { const { awsNaming, cfTemplate, fixtureData } = await runServerless({ fixture: 'function', - cliArgs: ['package'], + command: 'package', configExt: { provider: { ecr: { @@ -1138,7 +1140,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { fixtureData: { servicePath }, } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, }); @@ -1190,7 +1192,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { const { awsNaming, cfTemplate } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, }); @@ -1229,7 +1231,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { fixtureData: { servicePath }, } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': innerSpawnExtStub, @@ -1292,7 +1294,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { .throws({ stdBuffer: 'authorization token has expired' }); await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': innerSpawnExtStub, @@ -1327,7 +1329,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { const { stdoutData } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon @@ -1360,7 +1362,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { }; const { awsNaming, cfTemplate } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, configExt: { @@ -1405,7 +1407,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { fixtureData: { servicePath }, } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, configExt: { @@ -1461,7 +1463,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { fixtureData: { servicePath }, } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, configExt: { @@ -1520,7 +1522,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { fixtureData: { servicePath }, } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, configExt: { @@ -1577,7 +1579,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { }; const { awsNaming, cfTemplate } = await runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap, modulesCacheStub, configExt: { @@ -1609,7 +1611,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: baseAwsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon.stub().throws(), @@ -1622,7 +1624,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: baseAwsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon.stub().returns({}).onSecondCall().throws(), @@ -1635,7 +1637,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: baseAwsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon.stub().returns({}).onCall(2).throws(), @@ -1648,7 +1650,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: baseAwsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon.stub().returns({}).onCall(3).throws(), @@ -1661,7 +1663,7 @@ describe('test/unit/lib/plugins/aws/provider.test.js', () => { await expect( runServerless({ fixture: 'ecr', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: baseAwsRequestStubMap, modulesCacheStub: { 'child-process-ext/spawn': sinon diff --git a/test/unit/lib/plugins/aws/remove/index.test.js b/test/unit/lib/plugins/aws/remove/index.test.js index a8f9e31c444..de5ab0e9900 100644 --- a/test/unit/lib/plugins/aws/remove/index.test.js +++ b/test/unit/lib/plugins/aws/remove/index.test.js @@ -62,7 +62,7 @@ describe('test/unit/lib/plugins/aws/remove/index.test.js', () => { const { awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['remove'], + command: 'remove', awsRequestStubMap, }); @@ -86,7 +86,7 @@ describe('test/unit/lib/plugins/aws/remove/index.test.js', () => { const { awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['remove'], + command: 'remove', awsRequestStubMap, }); @@ -109,7 +109,7 @@ describe('test/unit/lib/plugins/aws/remove/index.test.js', () => { describeRepositoriesStub.resolves(); const { awsNaming } = await runServerless({ fixture: 'function', - cliArgs: ['remove'], + command: 'remove', awsRequestStubMap, }); @@ -125,7 +125,7 @@ describe('test/unit/lib/plugins/aws/remove/index.test.js', () => { const { stdoutData } = await runServerless({ fixture: 'ecr', - cliArgs: ['remove'], + command: 'remove', awsRequestStubMap, }); diff --git a/test/unit/lib/plugins/config.test.js b/test/unit/lib/plugins/config.test.js index 8e68e3f9f7e..e089709a204 100644 --- a/test/unit/lib/plugins/config.test.js +++ b/test/unit/lib/plugins/config.test.js @@ -6,7 +6,6 @@ const os = require('os'); const BbPromise = require('bluebird'); const { expect } = require('chai'); const config = require('@serverless/utils/config'); -const ServerlessError = require('../../../../lib/serverless-error'); const runServerless = require('../../../utils/run-serverless'); const isTabCompletionSupported = require('../../../../lib/utils/tabCompletion/isSupported'); @@ -19,28 +18,17 @@ const unexpected = () => { describe('Config', () => { it('should support "config credentials" command', () => runServerless({ - config: { service: 'foo', provider: 'aws' }, - cliArgs: ['config', 'credentials', '--provider', 'aws', '-k', 'foo', '-s', 'bar'], + noService: true, + command: 'config credentials', + options: { provider: 'aws', key: 'foo', secret: 'bar' }, })); - it('should have a required option "provider" for the "credentials" sub-command', () => - runServerless({ - config: { service: 'foo', provider: 'aws' }, - cliArgs: ['config', 'credentials', '-k', 'foo', '-s', 'bar'], - }).then(unexpected, (error) => expect(error).to.be.instanceof(ServerlessError))); - - it('should throw an error if user passed unsupported "provider" option', () => - runServerless({ - config: { service: 'foo', provider: 'aws' }, - cliArgs: ['config', 'credentials', '--provider', 'not-supported', '-k', 'foo', '-s', 'bar'], - }).then(unexpected, (error) => expect(error).to.be.instanceof(ServerlessError))); - if (isTabCompletionSupported) { it('should support "config tabcompletion install" command', () => runServerless({ cwd: os.homedir(), env: { SHELL: 'bash' }, - cliArgs: ['config', 'tabcompletion', 'install'], + command: 'config tabcompletion install', }).then(() => Promise.all([ fs @@ -57,12 +45,12 @@ describe('Config', () => { runServerless({ cwd: os.homedir(), env: { SHELL: 'bash' }, - cliArgs: ['config', 'tabcompletion', 'install'], + command: 'config tabcompletion install', }).then(() => runServerless({ cwd: os.homedir(), env: { SHELL: 'bash' }, - cliArgs: ['config', 'tabcompletion', 'uninstall'], + command: 'config tabcompletion uninstall', }).then(() => Promise.all([ fs @@ -79,7 +67,8 @@ describe('Config', () => { it('should turn on autoupdate with "--autoupdate"', async () => { await runServerless({ cwd: require('os').homedir(), - cliArgs: ['config', '--autoupdate'], + command: 'config', + options: { autoupdate: true }, modulesCacheStub: { './lib/utils/npmPackage/isGlobal.js': async () => true, './lib/utils/npmPackage/isWritable.js': async () => true, @@ -90,7 +79,8 @@ describe('Config', () => { it('should turn off autoupdate with "--no-autoupdate"', async () => { await runServerless({ cwd: __dirname, - cliArgs: ['config', '--no-autoupdate'], + command: 'config', + options: { autoupdate: false }, }); expect(config.get('autoUpdate.enabled')).to.be.false; }); diff --git a/test/unit/lib/plugins/interactiveCli/autoUpdate.test.js b/test/unit/lib/plugins/interactiveCli/autoUpdate.test.js index 79239a332e9..993ef6bbece 100644 --- a/test/unit/lib/plugins/interactiveCli/autoUpdate.test.js +++ b/test/unit/lib/plugins/interactiveCli/autoUpdate.test.js @@ -44,6 +44,7 @@ describe('interactiveCli: autoUpdate', () => { it('Should not suggest auto update in non supported environments', async () => { await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub: { ...modulesCacheStub, @@ -53,6 +54,7 @@ describe('interactiveCli: autoUpdate', () => { expect(configUtils.get('autoUpdate.enabled')).to.be.undefined; await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub: { ...modulesCacheStub, @@ -68,6 +70,7 @@ describe('interactiveCli: autoUpdate', () => { }); await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }); @@ -80,6 +83,7 @@ describe('interactiveCli: autoUpdate', () => { }); await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }); @@ -87,6 +91,7 @@ describe('interactiveCli: autoUpdate', () => { inquirer.prompt.restore(); await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub: { './lib/utils/npmPackage/isGlobal.js': async () => true, @@ -102,6 +107,7 @@ describe('interactiveCli: autoUpdate', () => { }); await runServerless({ noService: true, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }); diff --git a/test/unit/lib/plugins/interactiveCli/initializeService.test.js b/test/unit/lib/plugins/interactiveCli/initializeService.test.js index d61b83df371..ad77398daaa 100644 --- a/test/unit/lib/plugins/interactiveCli/initializeService.test.js +++ b/test/unit/lib/plugins/interactiveCli/initializeService.test.js @@ -38,6 +38,7 @@ describe('interactiveCli: initializeService', () => { it('Should be ineffective, when at service path', async () => runServerless({ cwd: join(fixturesPath, 'some-other-service'), + command: '', lifecycleHookNamesBlacklist, })); @@ -47,6 +48,7 @@ describe('interactiveCli: initializeService', () => { }); return runServerless({ cwd: fixturesPath, + command: '', pluginPathsWhitelist: ['./lib/plugins/interactiveCli'], lifecycleHookNamesBlacklist, }); @@ -59,6 +61,7 @@ describe('interactiveCli: initializeService', () => { }); return runServerless({ cwd: fixturesPath, + command: '', pluginPathsWhitelist: ['./lib/plugins/interactiveCli'], lifecycleHookNamesBlacklist, }); @@ -75,6 +78,7 @@ describe('interactiveCli: initializeService', () => { }); await runServerless({ cwd: fixturesPath, + command: '', pluginPathsWhitelist: ['./lib/plugins/interactiveCli'], lifecycleHookNamesBlacklist, }); @@ -93,6 +97,7 @@ describe('interactiveCli: initializeService', () => { await expect( runServerless({ cwd: fixturesPath, + command: '', pluginPathsWhitelist: ['./lib/plugins/interactiveCli'], lifecycleHookNamesBlacklist, }) @@ -108,6 +113,7 @@ describe('interactiveCli: initializeService', () => { await expect( runServerless({ cwd: fixturesPath, + command: '', pluginPathsWhitelist: ['./lib/plugins/interactiveCli'], lifecycleHookNamesBlacklist, }) diff --git a/test/unit/lib/plugins/interactiveCli/setupAws.test.js b/test/unit/lib/plugins/interactiveCli/setupAws.test.js index d16f92e295d..ba5f8400d5d 100644 --- a/test/unit/lib/plugins/interactiveCli/setupAws.test.js +++ b/test/unit/lib/plugins/interactiveCli/setupAws.test.js @@ -49,18 +49,21 @@ describe('interactiveCli: setupAws', () => { it('Should be ineffective, when not at service path', () => runServerless({ cwd: fixturesPath, + command: '', lifecycleHookNamesBlacklist, })); it('Should be ineffective, when not at AWS service', () => runServerless({ cwd: join(fixturesPath, 'some-other-service'), + command: '', lifecycleHookNamesBlacklist, })); it('Should be ineffective, when credentials are set in environment', () => runServerless({ cwd: awsProjectPath, + command: '', env: { AWS_ACCESS_KEY_ID: accessKeyId, AWS_SECRET_ACCESS_KEY: secretAccessKey }, lifecycleHookNamesBlacklist, })); @@ -69,6 +72,7 @@ describe('interactiveCli: setupAws', () => { configureInquirerStub(inquirer, { confirm: { shouldSetupAwsCredentials: false } }); return runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, }); }); @@ -108,6 +112,7 @@ describe('interactiveCli: setupAws', () => { it('Should be ineffective, When credentials are set in AWS config', () => runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, })); }); @@ -124,6 +129,7 @@ describe('interactiveCli: setupAws', () => { }); return runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }).then(() => { @@ -143,6 +149,7 @@ describe('interactiveCli: setupAws', () => { }); return runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }).then(() => { @@ -161,6 +168,7 @@ describe('interactiveCli: setupAws', () => { }); return runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }).then( @@ -178,6 +186,7 @@ describe('interactiveCli: setupAws', () => { }); return runServerless({ cwd: awsProjectPath, + command: '', lifecycleHookNamesBlacklist, modulesCacheStub, }).then( diff --git a/test/unit/lib/plugins/interactiveCli/tabCompletion.test.js b/test/unit/lib/plugins/interactiveCli/tabCompletion.test.js index acb89ed4d63..f55e22d9dd1 100644 --- a/test/unit/lib/plugins/interactiveCli/tabCompletion.test.js +++ b/test/unit/lib/plugins/interactiveCli/tabCompletion.test.js @@ -43,6 +43,7 @@ describe('interactiveCli: tabCompletion', () => { it('Should not suggest tab completion setup in non supported environments', () => { return runServerless({ cwd: os.homedir(), + command: '', lifecycleHookNamesBlacklist, }); }); @@ -55,6 +56,7 @@ describe('interactiveCli: tabCompletion', () => { }); return runServerless({ cwd: os.homedir(), + command: '', lifecycleHookNamesBlacklist, }); }); @@ -65,11 +67,13 @@ describe('interactiveCli: tabCompletion', () => { }); return runServerless({ cwd: os.homedir(), + command: '', lifecycleHookNamesBlacklist, }).then(() => { inquirer.prompt.restore(); return runServerless({ cwd: os.homedir(), + command: '', lifecycleHookNamesBlacklist, }); }); @@ -82,6 +86,7 @@ describe('interactiveCli: tabCompletion', () => { }); return runServerless({ cwd: os.homedir(), + command: '', env: { SHELL: 'bash' }, lifecycleHookNamesBlacklist, }).then(() => diff --git a/test/unit/lib/plugins/package/lib/packageService.test.js b/test/unit/lib/plugins/package/lib/packageService.test.js index e295054a2b2..3f07ad89376 100644 --- a/test/unit/lib/plugins/package/lib/packageService.test.js +++ b/test/unit/lib/plugins/package/lib/packageService.test.js @@ -6,7 +6,7 @@ const chai = require('chai'); const sinon = require('sinon'); const { listFileProperties, listZipFiles } = require('../../../../../utils/fs'); const runServerless = require('../../../../../utils/run-serverless'); -const fixtures = require('../../../../../fixtures'); +const fixtures = require('../../../../../fixtures/programmatic'); // Configure chai chai.use(require('chai-as-promised')); @@ -45,7 +45,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { serverless: serverlessInstance, } = await runServerless({ fixture: 'packaging', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockedDescribeStacksResponse, configExt: { package: { @@ -139,7 +139,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { }, } = await runServerless({ fixture: 'packaging', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockedDescribeStacksResponse, configExt: { useDotenv: true, @@ -165,7 +165,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { serverless: serverlessInstance, } = await runServerless({ fixture: 'packaging', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockedDescribeStacksResponse, configExt: { package: { @@ -223,7 +223,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { before(async () => { const { serverless: serverlessInstance } = await runServerless({ fixture: 'packaging', - cliArgs: ['package'], + command: 'package', awsRequestStubMap: mockedDescribeStacksResponse, configExt: { package: { @@ -311,7 +311,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { await runServerless({ cwd: servicePath, - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:uploadArtifacts', awsRequestStubMap, }); @@ -333,7 +333,7 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { }); await runServerless({ cwd: servicePath, - cliArgs: ['deploy'], + command: 'deploy', lastLifecycleHookName: 'aws:deploy:deploy:uploadArtifacts', awsRequestStubMap, }); @@ -379,7 +379,8 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { }); await runServerless({ cwd: servicePath, - cliArgs: ['deploy', '-f', 'other'], + command: 'deploy function', + options: { function: 'other' }, awsRequestStubMap, }); expect(updateFunctionCodeStub).to.have.been.calledOnce; @@ -398,7 +399,8 @@ describe('lib/plugins/package/lib/packageService.test.js', () => { }); await runServerless({ cwd: servicePath, - cliArgs: ['deploy', '-f', 'foo'], + command: 'deploy function', + options: { function: 'foo' }, awsRequestStubMap, }); expect(updateFunctionCodeStub).to.have.been.calledOnce; diff --git a/test/unit/lib/plugins/print.test.js b/test/unit/lib/plugins/print.test.js index 05e1333e455..5cfdca5bc43 100644 --- a/test/unit/lib/plugins/print.test.js +++ b/test/unit/lib/plugins/print.test.js @@ -337,7 +337,7 @@ describe('test/unit/lib/plugins/print.test.js', () => { it('correctly prints config', async () => { const { stdoutData } = await runServerless({ fixture: 'aws', - cliArgs: ['print'], + command: 'print', }); expect(stdoutData).to.include('name: aws'); diff --git a/test/unit/lib/utils/analytics/generatePayload.test.js b/test/unit/lib/utils/analytics/generatePayload.test.js index a33f94e5008..7a60ab537e6 100644 --- a/test/unit/lib/utils/analytics/generatePayload.test.js +++ b/test/unit/lib/utils/analytics/generatePayload.test.js @@ -8,7 +8,7 @@ const overrideEnv = require('process-utils/override-env'); const generatePayload = require('../../../../../lib/utils/analytics/generatePayload'); const runServerless = require('../../../../utils/run-serverless'); -const fixtures = require('../../../../fixtures'); +const fixtures = require('../../../../fixtures/programmatic'); const versions = { 'serverless': require('../../../../../package').version, @@ -47,7 +47,7 @@ describe('lib/utils/analytics/generatePayload', () => { const { serverless } = await runServerless({ cwd: servicePath, - cliArgs: ['-v'], + command: '-v', }); const payload = await generatePayload(serverless); @@ -93,7 +93,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should resolve payload for custom provider service', async () => { const { serverless } = await runServerless({ fixture: 'customProvider', - cliArgs: ['config'], + command: 'config', }); const payload = await generatePayload(serverless); @@ -136,7 +136,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should recognize local fallback', async () => { const { serverless } = await runServerless({ fixture: 'locallyInstalledServerless', - cliArgs: ['config'], + command: 'config', modulesCacheStub: {}, }); const payload = await generatePayload(serverless); @@ -177,7 +177,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should resolve payload with predefined local config', async () => { const { serverless } = await runServerless({ fixture: 'customProvider', - cliArgs: ['config'], + command: 'config', }); await fs.promises.writeFile( @@ -200,7 +200,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should not include userId from local config if SERVERLESS_ACCESS_KEY used', async () => { const { serverless } = await runServerless({ fixture: 'customProvider', - cliArgs: ['config'], + command: 'config', }); await fs.promises.writeFile( @@ -223,7 +223,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should correctly detect Serverless CI/CD', async () => { const { serverless } = await runServerless({ fixture: 'customProvider', - cliArgs: ['config'], + command: 'config', }); let payload; @@ -237,7 +237,7 @@ describe('lib/utils/analytics/generatePayload', () => { it('Should correctly detect Seed CI/CD', async () => { const { serverless } = await runServerless({ fixture: 'customProvider', - cliArgs: ['config'], + command: 'config', }); let payload; diff --git a/test/unit/lib/utils/logDeprecation.test.js b/test/unit/lib/utils/logDeprecation.test.js index 80ae859fed8..cc798040923 100644 --- a/test/unit/lib/utils/logDeprecation.test.js +++ b/test/unit/lib/utils/logDeprecation.test.js @@ -51,7 +51,7 @@ describe('#logDeprecation()', () => { return runServerless({ fixture: 'function', configExt: { disabledDeprecations: ['CODE1'] }, - cliArgs: ['package'], + command: 'package', }).then(({ serverless }) => { const serviceConfig = serverless.service; let stdoutData = ''; @@ -79,7 +79,7 @@ describe('#logDeprecation()', () => { return runServerless({ fixture: 'function', configExt: { disabledDeprecations: '*' }, - cliArgs: ['package'], + command: 'package', }).then(({ serverless }) => { const serviceConfig = serverless.service; let stdoutData = ''; diff --git a/test/unit/scripts/serverless.test.js b/test/unit/scripts/serverless.test.js index c4a8f29be0f..523ba9df598 100644 --- a/test/unit/scripts/serverless.test.js +++ b/test/unit/scripts/serverless.test.js @@ -5,11 +5,13 @@ const { expect } = require('chai'); const path = require('path'); const fs = require('fs').promises; const spawn = require('child-process-ext/spawn'); +const stripAnsi = require('strip-ansi'); const { version } = require('../../../package'); -const fixturesEngine = require('../../fixtures'); +const programmaticFixturesEngine = require('../../fixtures/programmatic'); const serverlessPath = path.resolve(__dirname, '../../../scripts/serverless.js'); -const fixturesPath = path.resolve(__dirname, '../../fixtures'); +const programmaticFixturesPath = path.resolve(__dirname, '../../fixtures/programmatic'); +const cliFixturesPath = path.resolve(__dirname, '../../fixtures/cli'); describe('test/unit/scripts/serverless.test.js', () => { it('should display version when "--version" option', async () => { @@ -21,7 +23,7 @@ describe('test/unit/scripts/serverless.test.js', () => { const output = String( ( await spawn('node', [serverlessPath, '--help'], { - cwd: path.resolve(fixturesPath, 'configSyntaxError'), + cwd: path.resolve(cliFixturesPath, 'configSyntaxError'), }) ).stdoutBuffer ); @@ -31,7 +33,7 @@ describe('test/unit/scripts/serverless.test.js', () => { it('should report with an error invalid configuration', async () => { try { await spawn('node', [serverlessPath, 'print'], { - cwd: path.resolve(fixturesPath, 'configSyntaxError'), + cwd: path.resolve(cliFixturesPath, 'configSyntaxError'), }); throw new Error('Unexpected'); } catch (error) { @@ -43,7 +45,7 @@ describe('test/unit/scripts/serverless.test.js', () => { it('should handle exceptions', async () => { try { await spawn('node', [serverlessPath, 'print'], { - cwd: path.resolve(fixturesPath, 'exception'), + cwd: path.resolve(programmaticFixturesPath, 'exception'), }); throw new Error('Unexpected'); } catch (error) { @@ -55,7 +57,7 @@ describe('test/unit/scripts/serverless.test.js', () => { it('should handle uncaught exceptions', async () => { try { await spawn('node', [serverlessPath, 'print'], { - cwd: path.resolve(fixturesPath, 'uncaughtException'), + cwd: path.resolve(cliFixturesPath, 'uncaughtException'), }); throw new Error('Unexpected'); } catch (error) { @@ -68,7 +70,7 @@ describe('test/unit/scripts/serverless.test.js', () => { const output = String( ( await spawn('node', [serverlessPath, '--help'], { - cwd: (await fixturesEngine.setup('locallyInstalledServerless')).servicePath, + cwd: (await programmaticFixturesEngine.setup('locallyInstalledServerless')).servicePath, }) ).stdoutBuffer ); @@ -79,7 +81,7 @@ describe('test/unit/scripts/serverless.test.js', () => { const output = String( ( await spawn('node', [serverlessPath, 'plugin', 'list'], { - cwd: path.resolve(fixturesPath, 'configSyntaxError'), + cwd: path.resolve(cliFixturesPath, 'configSyntaxError'), }) ).stdoutBuffer ); @@ -91,7 +93,7 @@ describe('test/unit/scripts/serverless.test.js', () => { String( ( await spawn('node', [serverlessPath, 'print'], { - cwd: path.resolve(fixturesPath, 'variables'), + cwd: path.resolve(cliFixturesPath, 'variables'), }) ).stdoutBuffer ) @@ -102,7 +104,7 @@ describe('test/unit/scripts/serverless.test.js', () => { try { await spawn('node', [serverlessPath, 'print'], { cwd: ( - await fixturesEngine.setup('aws', { + await programmaticFixturesEngine.setup('aws', { configExt: { variablesResolutionMode: '20210326', provider: '${foo:bar}' }, }) ).servicePath, @@ -118,7 +120,7 @@ describe('test/unit/scripts/serverless.test.js', () => { try { await spawn('node', [serverlessPath, 'print'], { cwd: ( - await fixturesEngine.setup('aws', { + await programmaticFixturesEngine.setup('aws', { configExt: { variablesResolutionMode: '20210326', provider: { stage: '${foo:bar}' } }, }) ).servicePath, @@ -131,7 +133,7 @@ describe('test/unit/scripts/serverless.test.js', () => { }); it('should load env variables from dotenv files', async () => { - const { servicePath } = await fixturesEngine.setup('aws', { + const { servicePath } = await programmaticFixturesEngine.setup('aws', { configExt: { useDotenv: true, custom: { @@ -149,7 +151,7 @@ describe('test/unit/scripts/serverless.test.js', () => { try { await spawn('node', [serverlessPath, 'print'], { cwd: ( - await fixturesEngine.setup('aws', { + await programmaticFixturesEngine.setup('aws', { configExt: { variablesResolutionMode: '20210326', plugins: '${foo:bar}' }, }) ).servicePath, @@ -165,7 +167,7 @@ describe('test/unit/scripts/serverless.test.js', () => { const output = String( ( await spawn('node', [serverlessPath, '--help'], { - cwd: path.resolve(fixturesPath, 'configInvalid'), + cwd: path.resolve(programmaticFixturesPath, 'configInvalid'), }) ).stdoutBuffer ); @@ -182,4 +184,22 @@ describe('test/unit/scripts/serverless.test.js', () => { expect(output).to.include('deploy'); expect(output).to.include('stage'); }); + + it('should show help when running container command', async () => { + // Note: Arbitrarily picked "plugin" command for testing + const output = stripAnsi( + String((await spawn('node', [serverlessPath, 'plugin'])).stdoutBuffer) + ); + expect(output).to.include('plugin install .......'); + }); + + it('should crash in required option is missing', async () => { + try { + await spawn('node', [serverlessPath, 'config', 'credentials', '-k', 'foo', '-s', 'bar']); + throw new Error('Unexpected'); + } catch (error) { + expect(error.code).to.equal(1); + expect(String(error.stdoutBuffer)).to.include('command requires the'); + } + }); }); diff --git a/test/utils/run-serverless.js b/test/utils/run-serverless.js index dee30246100..06aabd8a45f 100644 --- a/test/utils/run-serverless.js +++ b/test/utils/run-serverless.js @@ -3,6 +3,6 @@ const path = require('path'); module.exports = require('@serverless/test/setup-run-serverless-fixtures-engine')({ - fixturesDir: path.resolve(__dirname, '../fixtures'), + fixturesDir: path.resolve(__dirname, '../fixtures/programmatic'), serverlessDir: path.resolve(__dirname, '../../'), });