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

fix(cloudformation-diff): format test #30509

Closed
wants to merge 2 commits into from

Conversation

ChakshuGupta13
Copy link

@ChakshuGupta13 ChakshuGupta13 commented Jun 10, 2024

Reason for this change

Currently, yarn build fails in '@aws-cdk-testing' package with following error because 'Received' string is formatted with chalk.red and 'Expected' string is by default formatted with chalk.green:

   ✖  @aws-cdk/cloudformation-diff:test
$ cdk-test
       FAIL  test/format.test.ts
        ● format value can handle partial json strings

          expect(received).toEqual(expected) // deep equality

          Expected: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}"
          Received: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}"

            6 | test('format value can handle partial json strings', () => {
            7 |   const output = formatter.formatValue({ nice: 'great', partialJson: '{"wow": "great' }, chalk.red);
          > 8 |   expect(output).toEqual('{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}');
              |                  ^
            9 | });

            at Object.<anonymous> (test/format.test.ts:8:18)

Description of changes

As unit-test aims to test equality of strings in terms of content instead of color formatting, hence, it is better to utilise toMatch instead of toEqual.

Description of how you validated changes

Upon retesting, unit-test passed:

 ✔  @aws-cdk/cloudformation-diff:build  [local cache]

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team June 10, 2024 14:41
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Jun 10, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@ChakshuGupta13
Copy link
Author

Exemption Request

Reason: Change has been made to unit-test and not source, hence, change to an integration test file does not make sense:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jun 10, 2024
@ChakshuGupta13 ChakshuGupta13 marked this pull request as ready for review June 10, 2024 14:52
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 10, 2024
Copy link
Contributor

@mmuller88 mmuller88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@ChakshuGupta13
Copy link
Author

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 7448549
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Unrelated test failures:

aws-cdk: Summary of all failing tests
aws-cdk: FAIL test/diff.test.ts (12.235 s)
aws-cdk:   � imports › imports render correctly for an existing stack and diff creates a changeset
aws-cdk:     ENOENT: no such file or directory, lstat 'migrate.json'
aws-cdk:       161 |
aws-cdk:       162 |   afterEach(() => {
aws-cdk:     > 163 |     fs.rmSync('migrate.json');
aws-cdk:           |        ^
aws-cdk:       164 |   });
aws-cdk:       165 |
aws-cdk:       166 |   test('imports render correctly for a nonexistant stack without creating a changeset', async () => {
aws-cdk:       at Object.<anonymous> (test/diff.test.ts:163:8)
aws-cdk: FAIL test/cdk-toolkit.test.ts (19.333 s)
aws-cdk:   � readCurrentTemplate › dont lookup bootstrap version parameter if default credentials are used
aws-cdk:     expect(received).toEqual(expected) // deep equality
aws-cdk:     - Expected  - 1
aws-cdk:     + Received  + 2
aws-cdk:       Object {
aws-cdk:     -   "assumeRoleArn": "bloop-lookup:here:123456789012",
aws-cdk:     +   "assumeRoleArn": "bloop:here:123456789012",
aws-cdk:     +   "assumeRoleExternalId": undefined,
aws-cdk:       }
aws-cdk:       353 |     expect(mockCloudExecutable.sdkProvider.sdk.ssm).not.toHaveBeenCalled();
aws-cdk:       354 |     expect(mockForEnvironment.mock.calls.length).toEqual(3);
aws-cdk:     > 355 |     expect(mockForEnvironment.mock.calls[0][2]).toEqual({
aws-cdk:           |                                                 ^
aws-cdk:       356 |       assumeRoleArn: 'bloop-lookup:here:123456789012',
aws-cdk:       357 |     });
aws-cdk:       358 |     expect(mockForEnvironment.mock.calls[1][2]).toEqual({
aws-cdk:       at Object.<anonymous> (test/cdk-toolkit.test.ts:355:49)

- Currently, `yarn build` fails in '@aws-cdk-testing' package with following error because 'Received' string is formatted with `chalk.red` and 'Expected' string is by default formatted with `chalk.green`:

```
   ✖  @aws-cdk/cloudformation-diff:test
$ cdk-test
       FAIL  test/format.test.ts
        ● format value can handle partial json strings

          expect(received).toEqual(expected) // deep equality

          Expected: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}"
          Received: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}"

            6 | test('format value can handle partial json strings', () => {
            7 |   const output = formatter.formatValue({ nice: 'great', partialJson: '{"wow": "great' }, chalk.red);
          > 8 |   expect(output).toEqual('{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}');
              |                  ^
            9 | });

            at Object.<anonymous> (test/format.test.ts:8:18)
```

- But as unit-test aims to test equality of strings in terms of content instead of color formatting, hence, it is better to utilise `toMatch` instead of `toEqual`.
- Upon retesting, unit-test passed:

```
 ✔  @aws-cdk/cloudformation-diff:build  [local cache]
```
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: d42f2e7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Jul 10, 2024
@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@ChakshuGupta13 ChakshuGupta13 deleted the format_test_fix branch July 10, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants