fix #927 check pull status code

Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
This commit is contained in:
Xian Chaobo 2015-07-07 17:41:12 +08:00
parent 463b058b6d
commit 402053fa00
3 changed files with 17 additions and 1 deletions

2
Godeps/Godeps.json generated
View File

@ -105,7 +105,7 @@
},
{
"ImportPath": "github.com/samalba/dockerclient",
"Rev": "a78609286676d55688dcedf8a90522bc7d1bd569"
"Rev": "15ebe064ca62ad0d64834e7ef0d4ed8ce9d02cde"
},
{
"ImportPath": "github.com/samuel/go-zookeeper/zk",

View File

@ -453,7 +453,19 @@ func (client *DockerClient) PullImage(name string, auth *AuthConfig) error {
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 404 {
return ErrNotFound
}
if resp.StatusCode >= 400 {
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
return fmt.Errorf("%s", string(data))
}
var finalObj map[string]interface{}
for decoder := json.NewDecoder(resp.Body); err == nil; err = decoder.Decode(&finalObj) {
}

View File

@ -20,6 +20,10 @@ function teardown() {
# verify, container is running
[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]
# error check
run docker_swarm run -d 4e8aa3148a132f19ec560952231c4d39522043994df7d2dc239942c0f9424ebd
[[ "${output}" == *"cannot specify 64-byte hexadecimal strings"* ]]
}
@test "docker run with resources" {