1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

More unit tests for remote api

This commit is contained in:
Guillaume J. Charmes 2013-05-09 21:54:43 -07:00
parent 28fd289b44
commit 310fec4819

View file

@ -1,9 +1,12 @@
package docker package docker
import ( import (
"bufio"
"bytes" "bytes"
"encoding/json" "encoding/json"
"github.com/dotcloud/docker/auth" "github.com/dotcloud/docker/auth"
"io"
"net"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -270,24 +273,53 @@ func TestGetContainersExport(t *testing.T) {
t.Log("Test not implemented") t.Log("Test not implemented")
} }
func TestGetContainerChanges(t *testing.T) { func TestGetContainersChanges(t *testing.T) {
// FIXME: Implement this test runtime, err := newTestRuntime()
t.Log("Test on implemented") if err != nil {
// r := httptest.NewRecorder() t.Fatal(err)
}
defer nuke(runtime)
// req, err := http.NewRequest("GET", "/containers/"+id+"/changes", nil) srv := &Server{runtime: runtime}
// if err != nil {
// t.Fatal(err)
// }
// body, err := getContainersChanges(srv, r, req, nil) builder := NewBuilder(runtime)
// if err != nil {
// t.Fatal(err)
// }
// if body == nil { // Create a container and remove a file
// t.Fatalf("Body expected, received: nil\n") container, err := builder.Create(
// } &Config{
Image: GetTestImage(runtime).Id,
Cmd: []string{"/bin/rm", "/etc/passwd"},
},
)
if err != nil {
t.Fatal(err)
}
defer runtime.Destroy(container)
if err := container.Run(); err != nil {
t.Fatal(err)
}
body, err := getContainersChanges(srv, nil, nil, map[string]string{"name": container.Id})
if err != nil {
t.Fatal(err)
}
changes := []Change{}
if err := json.Unmarshal(body, &changes); err != nil {
t.Fatal(err)
}
// Check the changelog
success := false
for _, elem := range changes {
if elem.Path == "/etc/passwd" && elem.Kind == 2 {
success = true
}
}
if !success {
t.Fatalf("/etc/passwd as been removed but is not present in the diff")
}
}
func TestGetContainersByName(t *testing.T) { func TestGetContainersByName(t *testing.T) {
//FIXME: Implement this test //FIXME: Implement this test