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

Refactor to kotlin.assert and power-assert: example #191

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

tibtof
Copy link
Contributor

@tibtof tibtof commented Oct 23, 2023

A first example for #173

Copy link
Owner

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Looks great @tibtof! Two smalls nits.

Sorry for the slow review, I was sick all week 🤒

response.status shouldBe HttpStatusCode.OK
response.body<TagsResponse>().tags.toSet() shouldBe emptySet()
assert(response.status == HttpStatusCode.OK)
assert(response.body<TagsResponse>().tags.isEmpty())
Copy link
Owner

Choose a reason for hiding this comment

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

I think here we need to use == emptyList() in order to get a proper error message from power-assert.

Suggested change
assert(response.body<TagsResponse>().tags.isEmpty())
assert(response.body<TagsResponse>().tags == emptyList())

Copy link
Contributor Author

@tibtof tibtof Nov 5, 2023

Choose a reason for hiding this comment

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

I think the message for isEmpty is good enough, but if you prefer an equality check, I will refactor it. Here is a comparison:
image

image

src/test/kotlin/io/github/nomisrev/routes/TagRouteSpec.kt Outdated Show resolved Hide resolved
@tibtof
Copy link
Contributor Author

tibtof commented Oct 29, 2023

@nomisRev don't worry about it, and I hope you are well. I will also refactor the other asserts before resubmitting the review.

@tibtof
Copy link
Contributor Author

tibtof commented Nov 5, 2023

Hi @nomisRev, I implemented your suggestions, refactored the rest of the assertions and rebased the latest main. Please review it again. Thanks!

@tibtof tibtof requested a review from nomisRev November 5, 2023 14:33
Copy link
Owner

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you @tibtof.
Sorry for the late response, I needed some time off.

@nomisRev nomisRev merged commit 193b0ff into nomisRev:main Nov 23, 2023
1 check passed
@tibtof tibtof deleted the power-assert branch November 23, 2023 12:34
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