testcontainers-go
testcontainers-go copied to clipboard
fix: improve get container ip
Motivation
Get container ip sometimes empty, I check code and found that we return the inspect.NetworkSettings.IPAddress
. If this IP is empty, we should check the inspect.NetworkSettings.Networks
, it shouldn't empty.
Codecov Report
Merging #396 (900161b) into master (d303350) will decrease coverage by
0.10%
. The diff coverage is50.00%
.
:exclamation: Current head 900161b differs from pull request most recent head 97e4b7c. Consider uploading reports for the commit 97e4b7c to get more accurate results
@@ Coverage Diff @@
## master #396 +/- ##
==========================================
- Coverage 63.98% 63.88% -0.11%
==========================================
Files 18 18
Lines 1108 1113 +5
==========================================
+ Hits 709 711 +2
- Misses 295 298 +3
Partials 104 104
Impacted Files | Coverage Δ | |
---|---|---|
docker.go | 63.96% <50.00%> (-0.24%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update d303350...97e4b7c. Read the comment docs.
Looks like I should make a mock test, do you have any ideas?
Have a look at the TestContainerAttachedToNewNetwork
test in docker_test.go
it already 'covers' what you are trying to avoid.
I think it has something to do with whether a container is in the default bridge
network or in another non-default network. In the latter case your way of retrieving the IP is the only one working.
I'd say this PR has been already solved in #491. Please let us know if we can close it, thanks!