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

tests and fix for faking data for slice of structs with slice_len specified #19

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

cwinters8
Copy link
Contributor

@cwinters8 cwinters8 commented Feb 8, 2023

I was seeing Unknown Type errors when attempting to fake data for a slice of structs or slice of pointers to structs with the slice_len tag specified, which can be reproduced by running something similar to either of the added tests from this PR without the implemented fix in place. The fix here allows for generating fake data in these scenarios.

Open to any feedback you may have. I apologize for the linter making changes to some of the comments here. The Go linter in VS Code is opinionated 🤦‍♂️

@cwinters8 cwinters8 changed the title tests and fix for faking data for slice of structs tests and fix for faking data for slice of structs with slice_len specified Feb 8, 2023
@bxcodec
Copy link
Contributor

bxcodec commented Sep 20, 2023

Hi @cwinters8 , new update pushed to Master, can you help to pull the latest update and resolve the conflict, please?

@cwinters8
Copy link
Contributor Author

Hey @bxcodec I'm sorry for not getting to this for so long. I'm pulling this down again to resolve the conflict. New commit headed this way shortly.

@cwinters8
Copy link
Contributor Author

@bxcodec should be set! Let me know if there's anything else.

@cwinters8
Copy link
Contributor Author

I think the test check failed because TestGetRealAddress ended up randomly getting this address back from Address.realWorld, which gets a random address ultimately from the data stored in misc/addresses-us-1000.min.json:

{
  "address1": "3 Southerberry Drive",
  "address2": "",
  "state": "VT",
  "postalCode": "05468",
  "coordinates": { "lat": 44.62322460000001, "lng": -73.1326629 }
}

As you can see, that address doesn't have a city, and the test checks if the city is empty. When I run the tests locally using the same flags in the workflow step that failed, it doesn't fail, presumably because its grabbing some other address instead.

I just pushed a commit to fix the problem in the json file.

Copy link
Contributor

@bxcodec bxcodec left a comment

Choose a reason for hiding this comment

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

LGTM

@bxcodec bxcodec merged commit 3032a45 into go-faker:main Feb 7, 2024
2 checks passed
@bxcodec
Copy link
Contributor

bxcodec commented Feb 7, 2024

Thanks @cwinters8 , merged

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