From bf8e0277bbd1c2df2310bc20ecc4003d1ed7a657 Mon Sep 17 00:00:00 2001 From: Mark Allen Date: Thu, 7 Nov 2013 23:34:54 -0600 Subject: [PATCH] Add ImageInsert tests --- server_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/server_test.go b/server_test.go index 4072344f35..3376eebd6e 100644 --- a/server_test.go +++ b/server_test.go @@ -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) + } +}