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

test(http): basic endpoint tests #325

Merged
merged 6 commits into from
Jul 2, 2023

Conversation

mbhrznr
Copy link
Contributor

@mbhrznr mbhrznr commented Jul 1, 2023

closes #315.

this pr adds a bunch of simple tests to have some coverage on our endpoints.
as described in the issue, it simply follows the guide as described here.

additionally it tweaks the deleteVote function, as theoretically, one could've downvoted an item into oblivion.

@@ -286,11 +279,29 @@ export async function deleteVote(vote: Vote) {
vote.user.id,
];

const [votedItemsByUserRes, votedUsersByItemRes] = await kv.getMany([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is something i stumbled upon by accident.
if we compare createVote and deleteVote, we were missing a check for the votedItemsByUserKey and votedUsersByItemKey results.

as the deletion for a non-existent key doesn't throw (anymore?), the mutation on the vote.item.score would've been abused via api calls.

this is why an explicit check for these keys and their respective results has been introduced.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Though, next time, let's keep the objectives per PR to 1 🙂

@iuioiua
Copy link
Contributor

iuioiua commented Jul 1, 2023

I half expected this - test coverage has taken a significant hit now that more files are included in the tested list. What to do...

@iuioiua
Copy link
Contributor

iuioiua commented Jul 2, 2023

Let's ignore test coverage for /routes, /components and /islands. See https://docs.codecov.com/docs/ignoring-paths

We're more concerned with test coverage of logic, which lies in the /utils folder. This may change in the future.

@mbhrznr mbhrznr force-pushed the test/basic-endpoint-tests branch from 2afbb0f to 67fdbfb Compare July 2, 2023 11:00
@mbhrznr
Copy link
Contributor Author

mbhrznr commented Jul 2, 2023

Let's ignore test coverage for /routes, /components and /islands. See https://docs.codecov.com/docs/ignoring-paths

added the ignore section as suggested.

didn't came to mind to check the coverage, yet it makes sense that we took this big hit.
due to manifest we'd import everything into the newly created http test set, correct?

as for the now ignored dirs it might make sense to introduce e2e tests at some point, wdyt?

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this 🙏🏾

@@ -286,11 +279,29 @@ export async function deleteVote(vote: Vote) {
vote.user.id,
];

const [votedItemsByUserRes, votedUsersByItemRes] = await kv.getMany([
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch! Though, next time, let's keep the objectives per PR to 1 🙂

tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
tests/http_test.ts Outdated Show resolved Hide resolved
@iuioiua
Copy link
Contributor

iuioiua commented Jul 2, 2023

Let's ignore test coverage for /routes, /components and /islands. See https://docs.codecov.com/docs/ignoring-paths

added the ignore section as suggested.

didn't came to mind to check the coverage, yet it makes sense that we took this big hit. due to manifest we'd import everything into the newly created http test set, correct?

as for the now ignored dirs it might make sense to introduce e2e tests at some point, wdyt?

Yep! In fact, what if we move the newly created e2e tests from this PR to the root of the folder and name it e2e_test.ts?

Copy link
Contributor

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this!

@iuioiua iuioiua merged commit fc2fe5e into denoland:main Jul 2, 2023
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.

todo: basic endpoint testing
2 participants