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: introduce types.ftl.go to register sumtypes, which fixes encoding in unit tests #1909

Merged
merged 7 commits into from
Jul 2, 2024

Conversation

deniseli
Copy link
Contributor

Fixes #1577

This change introduces a new generated file types.ftl.go in the user-defined package itself to make sure sumtype registrations get called when running unit tests.

Notes:

  • This change also includes a subpackage subpackage in the test data that is not yet unit tested. Unit tests should be added (identical to the parent package's unit tests) after Can't define enums in sub-packages #1903 is resolved. Some work will also need to be done to extend the types.ftl.go generation to working on subpackages.
  • This works by extending the existing logic operating on mainModuleContext, which means that code now generates not only just the literal main package, but also the conceptual main package's additional artifacts. I couldn't come up with a name that would be better, so it's left as-is in this PR, but please let me know if you think of something better.

@deniseli deniseli force-pushed the dli/620-sumtype-reg branch from 8a88bd9 to 8fa58ec Compare June 28, 2024 19:22
@deniseli deniseli marked this pull request as ready for review June 28, 2024 20:18
@deniseli deniseli requested a review from alecthomas as a code owner June 28, 2024 20:18
@deniseli deniseli requested review from a team and matt2e and removed request for a team June 28, 2024 20:18
@ftl-robot ftl-robot mentioned this pull request Jun 28, 2024
@deniseli deniseli force-pushed the dli/620-sumtype-reg branch 2 times, most recently from 7785c2d to 4afcf6c Compare July 1, 2024 19:28
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Awesome. Have you played with it? What are the ergonomics like as you're updating the code/modifying the sum types?

.gitignore Outdated Show resolved Hide resolved
buildengine/discover_test.go Outdated Show resolved Hide resolved
buildengine/discover_test.go Outdated Show resolved Hide resolved
deniseli added 3 commits July 2, 2024 14:32
subpackage test

add failing integration test

move tests up to parent package

test passes

lint

encoding test

put main init back

rebuild

add new gened file to gitignore

rm gened file from git

fix path

simplify

fix discover test

comment fix
@deniseli deniseli force-pushed the dli/620-sumtype-reg branch from 9ae07d9 to 006c94c Compare July 2, 2024 18:33
@deniseli
Copy link
Contributor Author

deniseli commented Jul 2, 2024

Awesome. Have you played with it? What are the ergonomics like as you're updating the code/modifying the sum types?

It's been unintrusive, so good! Though I haven't tried it out in an IDE. Hopefully it works with everyone's workflows...

@deniseli deniseli merged commit 15a6ebf into main Jul 2, 2024
45 checks passed
@deniseli deniseli deleted the dli/620-sumtype-reg branch July 2, 2024 20:08
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.

We need to figure out a way to register sum types for the current module under ftltest
2 participants