|
@@ -369,10 +369,15 @@ func TestBuildApiDockerfilePath(t *testing.T) {
|
|
t.Fatalf("failed to close tar archive: %v", err)
|
|
t.Fatalf("failed to close tar archive: %v", err)
|
|
}
|
|
}
|
|
|
|
|
|
- _, out, err := sockRequestRaw("POST", "/build?dockerfile=../Dockerfile", buffer, "application/x-tar")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build?dockerfile=../Dockerfile", buffer, "application/x-tar")
|
|
if err == nil {
|
|
if err == nil {
|
|
|
|
+ out, _ := readBody(body)
|
|
t.Fatalf("Build was supposed to fail: %s", out)
|
|
t.Fatalf("Build was supposed to fail: %s", out)
|
|
}
|
|
}
|
|
|
|
+ out, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
if !strings.Contains(string(out), "must be within the build context") {
|
|
if !strings.Contains(string(out), "must be within the build context") {
|
|
t.Fatalf("Didn't complain about leaving build context: %s", out)
|
|
t.Fatalf("Didn't complain about leaving build context: %s", out)
|
|
@@ -393,10 +398,14 @@ RUN find /tmp/`,
|
|
}
|
|
}
|
|
defer server.Close()
|
|
defer server.Close()
|
|
|
|
|
|
- _, buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json")
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatalf("Build failed: %s", err)
|
|
t.Fatalf("Build failed: %s", err)
|
|
}
|
|
}
|
|
|
|
+ buf, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
// Make sure Dockerfile exists.
|
|
// Make sure Dockerfile exists.
|
|
// Make sure 'baz' doesn't exist ANYWHERE despite being mentioned in the URL
|
|
// Make sure 'baz' doesn't exist ANYWHERE despite being mentioned in the URL
|
|
@@ -419,10 +428,15 @@ RUN echo from dockerfile`,
|
|
}
|
|
}
|
|
defer git.Close()
|
|
defer git.Close()
|
|
|
|
|
|
- _, buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ buf, _ := readBody(body)
|
|
t.Fatalf("Build failed: %s\n%q", err, buf)
|
|
t.Fatalf("Build failed: %s\n%q", err, buf)
|
|
}
|
|
}
|
|
|
|
+ buf, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
out := string(buf)
|
|
out := string(buf)
|
|
if !strings.Contains(out, "from dockerfile") {
|
|
if !strings.Contains(out, "from dockerfile") {
|
|
@@ -445,10 +459,15 @@ RUN echo from Dockerfile`,
|
|
defer git.Close()
|
|
defer git.Close()
|
|
|
|
|
|
// Make sure it tries to 'dockerfile' query param value
|
|
// Make sure it tries to 'dockerfile' query param value
|
|
- _, buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json")
|
|
if err != nil {
|
|
if err != nil {
|
|
|
|
+ buf, _ := readBody(body)
|
|
t.Fatalf("Build failed: %s\n%q", err, buf)
|
|
t.Fatalf("Build failed: %s\n%q", err, buf)
|
|
}
|
|
}
|
|
|
|
+ buf, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
out := string(buf)
|
|
out := string(buf)
|
|
if !strings.Contains(out, "from baz") {
|
|
if !strings.Contains(out, "from baz") {
|
|
@@ -472,10 +491,14 @@ RUN echo from dockerfile`,
|
|
defer git.Close()
|
|
defer git.Close()
|
|
|
|
|
|
// Make sure it tries to 'dockerfile' query param value
|
|
// Make sure it tries to 'dockerfile' query param value
|
|
- _, buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Fatalf("Build failed: %s", err)
|
|
t.Fatalf("Build failed: %s", err)
|
|
}
|
|
}
|
|
|
|
+ buf, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
out := string(buf)
|
|
out := string(buf)
|
|
if !strings.Contains(out, "from Dockerfile") {
|
|
if !strings.Contains(out, "from Dockerfile") {
|
|
@@ -503,10 +526,15 @@ func TestBuildApiDockerfileSymlink(t *testing.T) {
|
|
t.Fatalf("failed to close tar archive: %v", err)
|
|
t.Fatalf("failed to close tar archive: %v", err)
|
|
}
|
|
}
|
|
|
|
|
|
- _, out, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar")
|
|
|
|
|
|
+ _, body, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar")
|
|
if err == nil {
|
|
if err == nil {
|
|
|
|
+ out, _ := readBody(body)
|
|
t.Fatalf("Build was supposed to fail: %s", out)
|
|
t.Fatalf("Build was supposed to fail: %s", out)
|
|
}
|
|
}
|
|
|
|
+ out, err := readBody(body)
|
|
|
|
+ if err != nil {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
|
|
// The reason the error is "Cannot locate specified Dockerfile" is because
|
|
// The reason the error is "Cannot locate specified Dockerfile" is because
|
|
// in the builder, the symlink is resolved within the context, therefore
|
|
// in the builder, the symlink is resolved within the context, therefore
|