Closed zombozo12 closed 2 years ago
For unit tests, I would recommend using the test databases provided by MaxMind.
If that doesn't work, I would suggest passing the reader into the code to be tested and using an interface so that you can easily mock it out.
first suggestion doesn't work for some reason I can't tell.
I did interfacing the reader, but in my case I need to initiate mmdb in main.go so it doesn't open every time I want to lookup. I tried to monkey patch the Open()
function, but it still return file not found even when I set the function to return nil
.
Hi, I was working with something using this library. When I came to unit test, we had a problem where mmdb files cannot be found. Is there a way to mock
mmdb.Open()
function?