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

feat(test) Unit test for updating pacakges #1007

Merged
merged 3 commits into from
Jan 10, 2025
Merged

Conversation

thwalker6
Copy link
Collaborator

@thwalker6 thwalker6 commented Jan 10, 2025

🎫 Linked Ticket

Ticket to close

💬 Description / Notes

Adding unit test coverage for the update lambda

🛠 Changes

Removed some unhittable exceptions we were doing. Since the zod object was verifying fields there was just a couple things not matter what you couldn't hit.

I also refactored some code by moving it around a little to make sure we are returning the values we want to in some cases.

📸 Screenshots / Demo

Copy link
Contributor

github-actions bot commented Jan 10, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 81.5% 7126 / 8743
🔵 Statements 80.43% 7443 / 9253
🔵 Functions 72.58% 2076 / 2860
🔵 Branches 50.34% 1390 / 2761
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
lib/lambda/search.test.ts 100% 100% 100% 100%
lib/lambda/update/updatePackage.test.ts 100% 100% 100% 100%
lib/lambda/update/updatePackage.ts 98.43% 88.09% 100% 98.43% 181
Generated in workflow #1450 for commit 48ed216 by the Vitest Coverage Report Action

@thwalker6 thwalker6 temporarily deployed to update-packages-test January 10, 2025 19:18 — with GitHub Actions Inactive
@thwalker6 thwalker6 temporarily deployed to update-packages-test January 10, 2025 19:19 — with GitHub Actions Inactive
@thwalker6 thwalker6 temporarily deployed to update-packages-test-app January 10, 2025 19:19 — with GitHub Actions Inactive
@thwalker6 thwalker6 temporarily deployed to update-packages-test-kibana January 10, 2025 19:19 — with GitHub Actions Inactive
@thwalker6 thwalker6 temporarily deployed to update-packages-test January 10, 2025 19:19 — with GitHub Actions Inactive
@@ -35,7 +37,7 @@ const items: Record<string, TestItemResult> = {
actionType: "New",
},
},
["VA"]: {
[WEIRD_ID]: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a certain check that wants to make sure an ID is just a wrong format for an item but it exist with in our system hence "weird"

const resultPackage = await handler(noActionevent);

expect(resultPackage.statusCode).toBe(400);
const noApackageEvent = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should probably split these into two tests just for clarity

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

split

@@ -102,7 +102,7 @@ const sendUpdateIdMessage = async ({
...remainingFields
} = currentPackage._source;

if (!updatedId) {
if (updatedId === currentPackage._id) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be if (!updatedId || updatedId === currentPackage._id) {?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its impossible for updatedId to not exist. Its set to default to packageId if one is not provided on line 192.

@thwalker6 thwalker6 merged commit b3f52d1 into main Jan 10, 2025
14 checks passed
@thwalker6 thwalker6 deleted the update-packages-test branch January 10, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants