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

test(cli): add avro util test cases #1752

Merged
merged 2 commits into from
Sep 5, 2024
Merged

test(cli): add avro util test cases #1752

merged 2 commits into from
Sep 5, 2024

Conversation

LAST7
Copy link
Collaborator

@LAST7 LAST7 commented Sep 4, 2024

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

Please describe the current behavior and link to a relevant issue.

Issue Number

What is the new behavior?

image

image

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

Are there any specific instructions or things that should be known prior to review?

Other information

1. change parameter `needFormat`'s type into `boolean` in function
`deserializedBufferToAvro`
2. little optimization to avoid calling `JSON.parse` twice
3. add function `clearCache`
4. export function `getAvroType` and `clearCache` for unit test
5. rename variable(s)
@ysfscream ysfscream added CLI MQTTX CLI test labels Sep 5, 2024
@ysfscream ysfscream added this to the v1.11.0 milestone Sep 5, 2024
@LAST7
Copy link
Collaborator Author

LAST7 commented Sep 5, 2024

I wonder whether I should mock fs.readFileSync function or not. Right now I'm putting two mock schema files in a sub-level directory.

@ysfscream
Copy link
Member

I wonder whether I should mock fs.readFileSync function or not. Right now I'm putting two mock schema files in a sub-level directory.

It's ok for me. Using real files makes the tests more authentic and effective. It tests actual file system interactions, which is valuable.

As long as your tests cover the key scenarios, there's no need to mock fs.readFileSync. Your current method shows the functionality.

@ysfscream ysfscream merged commit ee23a3d into emqx:main Sep 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI MQTTX CLI test
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants