Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Go generation code when schema just contains an enum#114

Merged
sixstone-qq merged 2 commits intomasterfrom
sixstone-003/conditional-import
Oct 4, 2022
Merged

Fix Go generation code when schema just contains an enum#114
sixstone-qq merged 2 commits intomasterfrom
sixstone-003/conditional-import

Conversation

@sixstone-qq
Copy link
Contributor

Before this PR, the following schema generated incorrected Go code:

{
     type: "enum"
     name: "MyEnum"
     symbols: ["a", "b", "c"]
}

Failed to generated corrected code.

Fixed by conditionally importing avrotypegen package only where is a record definition.

By conditionally importing `avrotypegen` package only where is a record
definition.
@sixstone-qq sixstone-qq added the bug Something isn't working label Oct 4, 2022
@sixstone-qq sixstone-qq self-assigned this Oct 4, 2022
)

var tests = testutil.RoundTripTest{
InSchema: `{
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity.
It's not easy to understand how these tests work.

Why do we need to define a schema.avsc and the InSchema?
They are equal

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 code is generated from CUE tests, that's the actual changes I did was adding a test. This test makes a roundtrip test:

  1. Parse schema
  2. Encode input data as binary with generated code
  3. Decode binary and make sure it's equal to original input data
    That's done for all generated tests.

@sixstone-qq sixstone-qq requested a review from jpcosal October 4, 2022 11:15
Copy link
Contributor

@jpcosal jpcosal left a comment

Choose a reason for hiding this comment

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

Nice addition! 🤗

@sixstone-qq sixstone-qq merged commit 0ca613a into master Oct 4, 2022
@sixstone-qq sixstone-qq deleted the sixstone-003/conditional-import branch October 4, 2022 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants