... | ... |
@@ -694,10 +694,82 @@ func TestPostImagesCreate(t *testing.T) { |
694 | 694 |
// }) |
695 | 695 |
} |
696 | 696 |
|
697 |
-// func TestPostImagesInsert(t *testing.T) { |
|
698 |
-// //FIXME: Implement this test (or remove this endpoint) |
|
699 |
-// t.Log("Test not implemented") |
|
700 |
-// } |
|
697 |
+func TestPostImagesInsert(t *testing.T) { |
|
698 |
+ // runtime, err := newTestRuntime() |
|
699 |
+ // if err != nil { |
|
700 |
+ // t.Fatal(err) |
|
701 |
+ // } |
|
702 |
+ // defer nuke(runtime) |
|
703 |
+ |
|
704 |
+ // srv := &Server{runtime: runtime} |
|
705 |
+ |
|
706 |
+ // stdin, stdinPipe := io.Pipe() |
|
707 |
+ // stdout, stdoutPipe := io.Pipe() |
|
708 |
+ |
|
709 |
+ // // Attach to it |
|
710 |
+ // c1 := make(chan struct{}) |
|
711 |
+ // go func() { |
|
712 |
+ // defer close(c1) |
|
713 |
+ // r := &hijackTester{ |
|
714 |
+ // ResponseRecorder: httptest.NewRecorder(), |
|
715 |
+ // in: stdin, |
|
716 |
+ // out: stdoutPipe, |
|
717 |
+ // } |
|
718 |
+ |
|
719 |
+ // req, err := http.NewRequest("POST", "/images/"+unitTestImageName+"/insert?path=%2Ftest&url=https%3A%2F%2Fraw.github.com%2Fdotcloud%2Fdocker%2Fmaster%2FREADME.md", bytes.NewReader([]byte{})) |
|
720 |
+ // if err != nil { |
|
721 |
+ // t.Fatal(err) |
|
722 |
+ // } |
|
723 |
+ // if err := postContainersCreate(srv, r, req, nil); err != nil { |
|
724 |
+ // t.Fatal(err) |
|
725 |
+ // } |
|
726 |
+ // }() |
|
727 |
+ |
|
728 |
+ // // Acknowledge hijack |
|
729 |
+ // setTimeout(t, "hijack acknowledge timed out", 5*time.Second, func() { |
|
730 |
+ // stdout.Read([]byte{}) |
|
731 |
+ // stdout.Read(make([]byte, 4096)) |
|
732 |
+ // }) |
|
733 |
+ |
|
734 |
+ // id := "" |
|
735 |
+ // setTimeout(t, "Waiting for imagesInsert output", 10*time.Second, func() { |
|
736 |
+ // for { |
|
737 |
+ // reader := bufio.NewReader(stdout) |
|
738 |
+ // id, err = reader.ReadString('\n') |
|
739 |
+ // if err != nil { |
|
740 |
+ // t.Fatal(err) |
|
741 |
+ // } |
|
742 |
+ // } |
|
743 |
+ // }) |
|
744 |
+ |
|
745 |
+ // // Close pipes (client disconnects) |
|
746 |
+ // if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil { |
|
747 |
+ // t.Fatal(err) |
|
748 |
+ // } |
|
749 |
+ |
|
750 |
+ // // Wait for attach to finish, the client disconnected, therefore, Attach finished his job |
|
751 |
+ // setTimeout(t, "Waiting for CmdAttach timed out", 2*time.Second, func() { |
|
752 |
+ // <-c1 |
|
753 |
+ // }) |
|
754 |
+ |
|
755 |
+ // img, err := srv.runtime.repositories.LookupImage(id) |
|
756 |
+ // if err != nil { |
|
757 |
+ // t.Fatalf("New image %s expected but not found", id) |
|
758 |
+ // } |
|
759 |
+ |
|
760 |
+ // layer, err := img.layer() |
|
761 |
+ // if err != nil { |
|
762 |
+ // t.Fatal(err) |
|
763 |
+ // } |
|
764 |
+ |
|
765 |
+ // if _, err := os.Stat(path.Join(layer, "test")); err != nil { |
|
766 |
+ // t.Fatalf("The test file has not been found") |
|
767 |
+ // } |
|
768 |
+ |
|
769 |
+ // if err := srv.runtime.graph.Delete(img.Id); err != nil { |
|
770 |
+ // t.Fatal(err) |
|
771 |
+ // } |
|
772 |
+} |
|
701 | 773 |
|
702 | 774 |
func TestPostImagesPush(t *testing.T) { |
703 | 775 |
//FIXME: Use staging in order to perform tests |
... | ... |
@@ -104,7 +104,7 @@ func (cli *DockerCli) CmdInsert(args ...string) error { |
104 | 104 |
v.Set("url", cmd.Arg(1)) |
105 | 105 |
v.Set("path", cmd.Arg(2)) |
106 | 106 |
|
107 |
- err := cli.hijack("POST", "/images/"+cmd.Arg(0)+"?"+v.Encode(), false) |
|
107 |
+ err := cli.hijack("POST", "/images/"+cmd.Arg(0)+"/insert?"+v.Encode(), false) |
|
108 | 108 |
if err != nil { |
109 | 109 |
return err |
110 | 110 |
} |