test: docker host-gateway

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-10-17 01:20:58 +02:00
parent 05af608774
commit 6c32a8c4c1
3 changed files with 27 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ var buildTests = []func(t *testing.T, sb integration.Sandbox){
testBuildCacheExportNotSupported,
testBuildOCIExportNotSupported,
testBuildMultiPlatformNotSupported,
testDockerHostGateway,
}
func testBuild(t *testing.T, sb integration.Sandbox) {
@@ -415,3 +416,19 @@ func testBuildMultiPlatformNotSupported(t *testing.T, sb integration.Sandbox) {
require.Error(t, err, string(out))
require.Contains(t, string(out), "Multi-platform build is not supported")
}
func testDockerHostGateway(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox
RUN ping -c 1 buildx.host-gateway-ip.local
`)
dir := tmpdir(t, fstest.CreateFile("Dockerfile", dockerfile, 0600))
cmd := buildxCmd(sb, withArgs("build", "--add-host=buildx.host-gateway-ip.local:host-gateway", "--output=type=cacheonly", dir))
out, err := cmd.CombinedOutput()
if !isDockerWorker(sb) {
require.Error(t, err, string(out))
require.Contains(t, string(out), "host-gateway is not supported")
} else {
require.NoError(t, err, string(out))
}
}