diff options
author | Emil Davtyan <emil2k@gmail.com> | 2018-01-30 13:35:22 +0100 |
---|---|---|
committer | Emil Davtyan <emil2k@gmail.com> | 2018-02-07 14:05:14 +0100 |
commit | 3e6bbefd268f51755be5af0644995297a71a05d7 (patch) | |
tree | bcba9a4ba6d36bbc8ddb9eaaead05ac4b2b35fb1 /client/task_inspect_test.go | |
parent | 40a9d5d24cda0d938f3c41dceef41b97b6b4e847 (diff) | |
download | docker-3e6bbefd268f51755be5af0644995297a71a05d7.tar.gz |
Produce errors when empty ids are passed into inspect calls.
If a blank nodeID was previously passed in it resulted in a node list
request. The response would then fail to umarshal into a `Node`
type returning a JSON error.
This adds an extra validation to all inspect calls to check that the ID
that is required is provided and if not return an error.
Signed-off-by: Emil Davtyan <emil2k@gmail.com>
Diffstat (limited to 'client/task_inspect_test.go')
-rw-r--r-- | client/task_inspect_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/client/task_inspect_test.go b/client/task_inspect_test.go index 148cdad3a7..910006731b 100644 --- a/client/task_inspect_test.go +++ b/client/task_inspect_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types/swarm" + "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -24,6 +25,18 @@ func TestTaskInspectError(t *testing.T) { } } +func TestTaskInspectWithEmptyID(t *testing.T) { + client := &Client{ + client: newMockClient(func(req *http.Request) (*http.Response, error) { + return nil, errors.New("should not make request") + }), + } + _, _, err := client.TaskInspectWithRaw(context.Background(), "") + if !IsErrNotFound(err) { + t.Fatalf("Expected NotFoundError, got %v", err) + } +} + func TestTaskInspect(t *testing.T) { expectedURL := "/tasks/task_id" client := &Client{ |