as part of my checking for valid urls, and it seems to be failing randomly in some tests, sometimes all the tests pass, sometimes 1-2 fail and the error is coming from here.
I am using google.com as the url, but i tried with other ones and it tends to happen with most.
To be even more exact the tests fail because the fixtures can’t be inserted while in the other 250+ cases it can
Any thoughts why can this happen?
What do you mean by “fail”? If by failing you mean the returned value does not match {:ok, _}, please tell us what it is instead. It might help to resolve the issue.
To clarify, you are using Cloudflare’s DNS. So the solution basically boils down to “do not use your ISP’s DNS servers”.
Additionally, I’m not sure why OP even does name resolution in tests. IPs can change, DNS servers might get offline at any time, and introduce chaos in your tests. And that’s exactly what happened.
hey, thanks for all the responses, i did not know that i can or should adjust the behavior of my validation in case it is being run in test env.
if that is the case, how would one go about that? I am using it in a changeset function to validate url input from users.
On the same note, if I am not running it in test mode, how do i know for sure that it works in a way that i’d expect?
Also what i am most surprised by, is that it runs perfectly most of the time like 99.8%. My other idea was that it might have to do with not having the most stellar internet, since it only seems to happen when I am running the tests locally, in the deployment pipeline it hasn’t failed yet . As for changing my dns, I am using that dns on router level, and I haven’t seen the tests fail since.