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

Migrated Snowflake to inline class #886

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zTrap
Copy link

@zTrap zTrap commented Oct 24, 2023

Mockk does not yet supported good boxing\unboxing for inline classes. So most equality check related tests are broken

Copy link
Member

@lukellmann lukellmann left a comment

Choose a reason for hiding this comment

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

can you run ./gradlew apiDump and commit the result? i want to know how bad it's going to be...

public constructor(value: ULong) {
this.value = value.coerceIn(validValues)
init {
value.coerceIn(validValues)
Copy link
Member

Choose a reason for hiding this comment

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

this won't do what you'd expect, the coerced value isn't used

there are a few options i can think of

  1. change coercion to exception
  2. hide the constructor and do coercion in a pseudo constructor (if that's even possible, i'm not sure)
  3. give up on limiting snowflakes and allow creating some that might be rejected by discord's api (see Note on valid Snowflake range discord/discord-api-docs#3745)

Comment on lines 195 to 185
public val validValues: ULongRange = ULong.MIN_VALUE..Long.MAX_VALUE.toULong() // 0..9223372036854775807
public val validValues: ULongRange = ULong.MIN_VALUE..ULong.MAX_VALUE // 0..9223372036854775807
Copy link
Member

Choose a reason for hiding this comment

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

why did you change this?

Comment on lines -23 to -26
/**
* The raw value of this Snowflake as specified by the
* [Discord Developer Documentation](https://discord.com/developers/docs/reference#snowflakes).
*/
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 this documentation should be kept

Comment on lines 99 to 97
Value(decoder.decodeInline(descriptor).decodeLong().toULong())
Value(Snowflake(decoder.decodeInline(descriptor).decodeLong().toULong()))
Copy link
Member

Choose a reason for hiding this comment

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

can be delegated to Snowflake's serializer instead

@lukellmann
Copy link
Member

Is there an issue already for the problems with mockk?

@zTrap
Copy link
Author

zTrap commented Oct 24, 2023

I've got wrong. This problem isn't related to inline classes, but to unsigned numbers. mockk/mockk#544

@lukellmann
Copy link
Member

I've got wrong. This problem isn't related to inline classes, but to unsigned numbers. mockk/mockk#544

the issue you pointed to is now closed, is there any update on this?

@zTrap
Copy link
Author

zTrap commented Feb 1, 2024

Yes, issue is closed, but it's not released yet

@zTrap zTrap force-pushed the feature/snowflake-inline-class branch from be60171 to eeac1bd Compare February 28, 2024 20:21
@zTrap zTrap force-pushed the feature/snowflake-inline-class branch from eeac1bd to 40e43ad Compare May 29, 2024 11:58
@zTrap
Copy link
Author

zTrap commented May 29, 2024

@lukellmann seems like all works fine with mockk v1.13.11

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.

None yet

2 participants