From e65e307753d2988ff91eed56a5ee0e6cd1ab5783 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Fri, 14 Apr 2017 16:01:56 -0700 Subject: [PATCH] Avoid using "example.com" in integration test This test appears to trigger HTTP requests to "example.com", which may explain why it is not behaving consistently. This changes it to use an internal HTTP server to avoid unexpected behavior caused by firewalls or proxies. Signed-off-by: Aaron Lehmann Upstream-commit: b483e4f09c128c2fabf82f787c0cf737c17c9c10 Component: engine --- .../engine/integration-cli/docker_api_images_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/engine/integration-cli/docker_api_images_test.go b/components/engine/integration-cli/docker_api_images_test.go index f27c9a2383..d44b307fa1 100644 --- a/components/engine/integration-cli/docker_api_images_test.go +++ b/components/engine/integration-cli/docker_api_images_test.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "net/http" + "net/http/httptest" "net/url" "strings" @@ -120,13 +121,16 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) { func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) { testRequires(c, Network) + server := httptest.NewServer(http.NewServeMux()) + defer server.Close() + tt := []struct { statusExp int fromSrc string }{ - {http.StatusNotFound, "http://example.com/nofile.tar"}, - {http.StatusNotFound, "example.com/nofile.tar"}, - {http.StatusNotFound, "example.com%2Fdata%2Ffile.tar"}, + {http.StatusNotFound, server.URL + "/nofile.tar"}, + {http.StatusNotFound, strings.TrimPrefix(server.URL, "http://") + "/nofile.tar"}, + {http.StatusNotFound, strings.TrimPrefix(server.URL, "http://") + "%2Fdata%2Ffile.tar"}, {http.StatusInternalServerError, "%2Fdata%2Ffile.tar"}, }