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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Tidy up tests and logging typos #24801

Merged
merged 4 commits into from
May 16, 2024

Conversation

adamdmharvey
Copy link
Member

@adamdmharvey adamdmharvey commented May 16, 2024

Hey, I just made a Pull Request!

馃Ч A tidy up PR to fix a few comments in tests and logging.

Also, the entity validator test was useless. It was testing that the metadata field is optional on entities, which the spec defines it is not:

"required": ["apiVersion", "kind", "metadata"],

The only reason the test was working, was because it was trying to delete a field which never existed, and testing if an object = the same object unmodified. If you fix the field name so the test actually does remove metadata, the test fails. So essentially the test is pointless, and I removed it.

I've intentionally not created a changesets for the two modified packages, as most are test updates and the others are trivial loggingedge cases which I thought weren't worth a release. Happy to have counter opinions.

鉁旓笍 Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

Signed-off-by: Adam Harvey <33203301+adamdmharvey@users.noreply.github.com>
@github-actions github-actions bot added the area:catalog Related to the Catalog Project Area label May 16, 2024
@backstage-goalie
Copy link
Contributor

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @backstage/backend-common
  • @backstage/backend-dynamic-feature-service

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/backend-common packages/backend-common none v0.22.0
@backstage/backend-dynamic-feature-service packages/backend-dynamic-feature-service none v0.2.10

The metadata field is required by schema, and this was testing if it was optional, passing only because it was misspelled.

Signed-off-by: Adam Harvey <33203301+adamdmharvey@users.noreply.github.com>
Signed-off-by: Adam Harvey <33203301+adamdmharvey@users.noreply.github.com>
Signed-off-by: Adam Harvey <33203301+adamdmharvey@users.noreply.github.com>
Comment on lines -68 to -71
it('handles missing metadata gracefully', async () => {
delete data.medatata;
await expect(policy.enforce(data)).resolves.toBe(data);
});
Copy link
Member Author

Choose a reason for hiding this comment

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

entities require metadata, so they shouldn't handle it being missing gracefully. test only passed because metadata was misspelled?

Copy link
Member Author

Choose a reason for hiding this comment

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

alternatively, could change this to throw an error if it's missing, just rewriting the test to reject missing metadata.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to drop 馃憤

It just throws "cannot read ... of undefined" anyway, so it's not really handling it at all. Metadata is required in the TS type too and it's up to the catalog processing engine to ensure that it exists.

@adamdmharvey adamdmharvey changed the title chore: Tidy up tests and some logging typos chore: Tidy up tests and logging typos May 16, 2024
@adamdmharvey adamdmharvey marked this pull request as ready for review May 16, 2024 04:06
@adamdmharvey adamdmharvey requested review from a team as code owners May 16, 2024 04:06
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

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

Thank you! 馃帀

Comment on lines -68 to -71
it('handles missing metadata gracefully', async () => {
delete data.medatata;
await expect(policy.enforce(data)).resolves.toBe(data);
});
Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to drop 馃憤

It just throws "cannot read ... of undefined" anyway, so it's not really handling it at all. Metadata is required in the TS type too and it's up to the catalog processing engine to ensure that it exists.

@Rugvip Rugvip merged commit 6ae2fab into backstage:master May 16, 2024
30 checks passed
Copy link
Contributor

Uffizzi Cluster pr-24801 was deleted.

@adamdmharvey adamdmharvey deleted the adamdmharvey-tidy-up branch May 16, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants