Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions samcli/commands/validate/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from samtranslator.translator.arn_generator import NoRegionFound

from samcli.cli.main import pass_context, common_options as cli_framework_options, aws_creds_options, print_cmdline_args
from samcli.commands._utils.cdk_support_decorators import unsupported_command_cdk
from samcli.commands._utils.options import template_option_without_build
from samcli.lib.telemetry.metric import track_command
from samcli.cli.cli_config_file import configuration_option, TomlProvider
Expand All @@ -25,6 +26,7 @@
@track_command
@check_newer_version
@print_cmdline_args
@unsupported_command_cdk(alternative_command="cdk doctor")
def cli(
ctx,
template_file,
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/validate/test_validate_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@ def test_default_template_file_choice(self, relative_folder: str, expected_file:
output = command_result.stdout.decode("utf-8")
self.assertEqual(command_result.process.returncode, 0)
self.assertRegex(output, pattern)

def test_validate_logs_warning_for_cdk_project(self):
test_data_path = Path(__file__).resolve().parents[2] / "integration" / "testdata" / "package"
template_file = "aws-serverless-function-cdk.yaml"
template_path = test_data_path.joinpath(template_file)
command_result = run_command(self.command_list(template_file=template_path))
output = command_result.stdout.decode("utf-8")

warning_message = (
"Warning: CDK apps are not officially supported with this command.\n"
"We recommend you use this alternative command: cdk doctor"
)

self.assertIn(warning_message, output)