Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

cli: cdk migrate command fails unit tests #27709

Closed
ymhiroki opened this issue Oct 27, 2023 · 2 comments
Closed

cli: cdk migrate command fails unit tests #27709

ymhiroki opened this issue Oct 27, 2023 · 2 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. package/tools Related to AWS CDK Tools or CLI

Comments

@ymhiroki
Copy link
Contributor

ymhiroki commented Oct 27, 2023

Describe the bug

I tried to build @aws-cdk to implement new features for an alpha module with yarn build, however, the tests for cdk migrate command in aws-cdk module failed.

Expected Behavior

aws-cdk module passes the all tests.

Current Behavior

Tests fail with errors:

Summary of all failing tests
        FAIL  test/cdk-toolkit.test.ts (29.148 s)
         ● synth › migrate › migrate fails when neither --from-path or --from-stack are provided
       
           expect(received).toContain(expected) // indexOf
       
           Expected substring: " ❌  Migrate failed for `no-source`: Either `--from-path` or `--from-stack` must be used to provide the source of the CloudFormation template."
           Received string:    " ❌  Migrate failed for `no-source`: Either `--from-path` or `--from-stack` must be used to provide the source of the CloudFormation template.
           "
       
             871 |       const toolkit = defaultToolkitSetup();
             872 |       await expect(() => toolkit.migrate({ stackName: 'no-source' })).rejects.toThrowError('Either `--from-path` or `--from-stack` must be used to provide the source of the CloudFormation template.');
           > 873 |       expect(stderrMock.mock.calls[1][0]).toContain(' ❌  Migrate failed for `no-source`: Either `--from-path` or `--from-stack` must be used to provide the source of the CloudFormation template.');
                 |                                           ^
             874 |     });
             875 |
             876 |     test('migrate fails when both --from-path and --from-stack are provided', async () => {
       
             at Object.<anonymous> (test/cdk-toolkit.test.ts:873:43)
       
         ● synth › migrate › migrate fails when both --from-path and --from-stack are provided
       
           expect(received).toContain(expected) // indexOf
       
           Expected substring: " ❌  Migrate failed for `no-source`: Only one of `--from-path` or `--from-stack` may be provided."
           Received string:    " ❌  Migrate failed for `no-source`: Only one of `--from-path` or `--from-stack` may be provided.
           "
       
             881 |         fromStack: true,
             882 |       })).rejects.toThrowError('Only one of `--from-path` or `--from-stack` may be provided.');
           > 883 |       expect(stderrMock.mock.calls[1][0]).toContain(' ❌  Migrate failed for `no-source`: Only one of `--from-path` or `--from-stack` may be provided.');
                 |                                           ^
             884 |     });
             885 |
             886 |     test('migrate fails when --from-path is invalid', async () => {
       
             at Object.<anonymous> (test/cdk-toolkit.test.ts:883:43)
       
         ● synth › migrate › migrate fails when --from-path is invalid
       
           expect(received).toContain(expected) // indexOf
       
           Expected substring: " ❌  Migrate failed for `bad-local-source`: './here/template.yml' is not a valid path."
           Received string:    " ❌  Migrate failed for `bad-local-source`: './here/template.yml' is not a valid path.
           "
       
             890 |         fromPath: './here/template.yml',
             891 |       })).rejects.toThrowError('\'./here/template.yml\' is not a valid path.');
           > 892 |       expect(stderrMock.mock.calls[1][0]).toContain(' ❌  Migrate failed for `bad-local-source`: \'./here/template.yml\' is not a valid path.');
                 |                                           ^
             893 |     });
             894 |
             895 |     test('migrate fails when --from-stack is used and stack does not exist in account', async () => {
       
             at Object.<anonymous> (test/cdk-toolkit.test.ts:892:43)
       
         ● synth › migrate › migrate fails when --from-stack is used and stack does not exist in account
       
           expect(received).toContain(expected) // indexOf
       
           Expected substring: " ❌  Migrate failed for `bad-cloudformation-source`: Stack does not exist in this environment"
           Received string:    " ❌  Migrate failed for `bad-cloudformation-source`: Stack does not exist in this environment
           "
       
             916 |         fromStack: true,
             917 |       })).rejects.toThrowError('Stack does not exist in this environment');
           > 918 |       expect(stderrMock.mock.calls[1][0]).toContain(' ❌  Migrate failed for `bad-cloudformation-source`: Stack does not exist in this environment');
                 |                                           ^
             919 |     });
             920 |
             921 |     test('migrate fails when stack cannot be generated', async () => {
       
             at Object.<anonymous> (test/cdk-toolkit.test.ts:918:43)
       
         ● synth › migrate › migrate fails when stack cannot be generated
       
           expect(received).toContain(expected) // indexOf
       
           Expected substring: " ❌  Migrate failed for `cannot-generate-template`: stack generation failed due to error 'unreachable'"
           Received string:    " ❌  Migrate failed for `cannot-generate-template`: stack generation failed due to error 'unreachable'
           "
       
             926 |         language: 'rust',
             927 |       })).rejects.toThrowError('stack generation failed due to error \'unreachable\'');
           > 928 |       expect(stderrMock.mock.calls[1][0]).toContain(' ❌  Migrate failed for `cannot-generate-template`: stack generation failed due to error \'unreachable\'');
                 |                                           ^
             929 |     });
             930 |
             931 |     cliTest('migrate succeeds for valid template from local path when no lanugage is provided', async (workDir) => {
       
             at Object.<anonymous> (test/cdk-toolkit.test.ts:928:43)
       
       
       Test Suites: 1 failed, 67 passed, 68 total
       Tests:       5 failed, 812 passed, 817 total
       Snapshots:   0 total
       Time:        44.369 s
       Ran all test suites.
       Error: /home/ec2-user/work/aws-cdk/node_modules/jest/bin/jest.js exited with error code 1
       Tests failed. Total time (44.9s) | /home/ec2-user/work/aws-cdk/node_modules/jest/bin/jest.js (44.9s)
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproduction Steps

cd packages/@aws-cdk
yarn build

Possible Solution

The difference between the expected value and the received value is the indention \n.
How about trimming the error message?

Additional Information/Context

No response

CDK CLI Version

2.103.1 (build 3bb19ac)

Framework Version

No response

Node.js Version

v16.20.2

OS

Amazon Linux2

Language

TypeScript

Language Version

No response

Other information

No response

@ymhiroki ymhiroki added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 27, 2023
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Oct 27, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@ymhiroki ymhiroki reopened this Oct 27, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

1 participant