From cee836fc39d32c724bb6c24bbeb0346dba38cc57 Mon Sep 17 00:00:00 2001 From: Sergii Kabashniuk Date: Mon, 30 Jan 2017 10:02:47 +0200 Subject: [PATCH] Added test for the case if ContentLength = -1 Signed-off-by: Sergii Kabashniuk Upstream-commit: 28d59e57ca0c718fe5d7531626be1fe3b9b6564a Component: engine --- components/engine/builder/remote_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/engine/builder/remote_test.go b/components/engine/builder/remote_test.go index 691a084761..588eb85015 100644 --- a/components/engine/builder/remote_test.go +++ b/components/engine/builder/remote_test.go @@ -151,6 +151,26 @@ func TestInspectResponseEmptyContentType(t *testing.T) { } } +func TestUnknownContentLength(t *testing.T) { + content := []byte(dockerfileContents) + ct := "text/plain" + br := ioutil.NopCloser(bytes.NewReader(content)) + contentType, bReader, err := inspectResponse(ct, br, -1) + if err != nil { + t.Fatal(err) + } + if contentType != "text/plain" { + t.Fatalf("Content type should be 'text/plain' but is %q", contentType) + } + body, err := ioutil.ReadAll(bReader) + if err != nil { + t.Fatal(err) + } + if string(body) != dockerfileContents { + t.Fatalf("Corrupted response body %s", body) + } +} + func TestMakeRemoteContext(t *testing.T) { contextDir, cleanup := createTestTempDir(t, "", "builder-tarsum-test") defer cleanup()