Add ImageInsert tests

Upstream-commit: bf8e0277bbd1c2df2310bc20ecc4003d1ed7a657
Component: engine
This commit is contained in:
Mark Allen
2013-11-07 23:34:54 -06:00
parent 5090a5bd4b
commit 807e6a9bd8

View File

@ -3,6 +3,7 @@ package docker
import (
"github.com/dotcloud/docker/utils"
"strings"
"io/ioutil"
"testing"
"time"
)
@ -521,3 +522,25 @@ func TestImagesFilter(t *testing.T) {
t.Fatal("incorrect number of matches returned")
}
}
func TestImageInsert(t *testing.T) {
runtime := mkRuntime(t)
defer nuke(runtime)
srv := &Server{runtime: runtime}
sf := utils.NewStreamFormatter(true)
// bad image name fails
if err := srv.ImageInsert("foo", "https://www.docker.io/static/img/docker-top-logo.png", "/foo", ioutil.Discard, sf); err == nil {
t.Fatal("expected an error and got none")
}
// bad url fails
if err := srv.ImageInsert(GetTestImage(runtime).ID, "http://bad_host_name_that_will_totally_fail.com/", "/foo", ioutil.Discard, sf); err == nil {
t.Fatal("expected an error and got none")
}
// success returns nil
if err := srv.ImageInsert(GetTestImage(runtime).ID, "https://www.docker.io/static/img/docker-top-logo.png", "/foo", ioutil.Discard, sf); err != nil {
t.Fatalf("expected no error, but got %v", err)
}
}