mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update tests to check returned errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
77c5668baf
commit
161e0a90a6
81 changed files with 359 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
)
|
||||
|
||||
func TestContainerCreateError(t *testing.T) {
|
||||
|
|
@ -21,6 +22,9 @@ func TestContainerCreateError(t *testing.T) {
|
|||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error while testing StatusInternalServerError, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error while testing StatusInternalServerError, got %T", err)
|
||||
}
|
||||
|
||||
// 404 doesn't automatically means an unknown image
|
||||
client = &Client{
|
||||
|
|
@ -30,6 +34,9 @@ func TestContainerCreateError(t *testing.T) {
|
|||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error while testing StatusNotFound, got %v", err)
|
||||
}
|
||||
if err == nil || !IsErrNotFound(err) {
|
||||
t.Fatalf("expected a Server Error while testing StatusNotFound, got %T", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerCreateImageNotFound(t *testing.T) {
|
||||
|
|
@ -38,7 +45,7 @@ func TestContainerCreateImageNotFound(t *testing.T) {
|
|||
}
|
||||
_, err := client.ContainerCreate(context.Background(), &container.Config{Image: "unknown_image"}, nil, nil, "unknown")
|
||||
if err == nil || !IsErrNotFound(err) {
|
||||
t.Fatalf("expected an imageNotFound error, got %v", err)
|
||||
t.Fatalf("expected an imageNotFound error, got %v, %T", err, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue