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

Fix package name extraction in code generation #1116

Merged

Conversation

pavlosgi
Copy link
Contributor

The old regex doesn't work properly on paths such as "src/main/scala/company/service/infra/graphql/model.scala". This returns "infra/graphql" as the package name. This is because of [] square brackets to match on one of scala, play or app. I replaced that with a non capturing regex group and that works as expected returning "company/service/infra/graphql" as the package name

@ghostdogpr
Copy link
Owner

Hi! That change makes one of the scripted tests fail, can you check it? (scripted in sbt to run it)

@pavlosgi pavlosgi force-pushed the feature/fix-package-name-codegen branch from 2617984 to 65c6e21 Compare October 29, 2021 16:03
@ghostdogpr
Copy link
Owner

It looks good! Do you mind adding a few unit tests to capture the different cases? Ideally with the 2 lines moved to a function.

@pavlosgi pavlosgi force-pushed the feature/fix-package-name-codegen branch 2 times, most recently from 55a8e95 to 6f94102 Compare October 30, 2021 12:25
@pavlosgi
Copy link
Contributor Author

Done

test("Package name is empty or default if path doesn't follow correct format") {
assert(packageAndObject("a/b/c", None, None))(
equalTo(None -> "Client")
)
Copy link
Owner

Choose a reason for hiding this comment

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

You need to join the assert with &&, otherwise only the last one will be executed (it's assert from zio-test, not the regular scala assert, it's a pure function that returns a test result).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@pavlosgi pavlosgi force-pushed the feature/fix-package-name-codegen branch from 6f94102 to b6bc7d7 Compare October 30, 2021 17:28
Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

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

Thanks!

@ghostdogpr ghostdogpr merged commit 338123c into ghostdogpr:master Oct 31, 2021
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