2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2017-06-07 16:09:07 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2017-06-07 16:09:07 +00:00
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2018-01-30 12:35:22 +00:00
|
|
|
"github.com/pkg/errors"
|
2018-06-11 13:32:11 +00:00
|
|
|
"gotest.tools/assert"
|
|
|
|
is "gotest.tools/assert/cmp"
|
2017-06-07 16:09:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDistributionInspectUnsupported(t *testing.T) {
|
|
|
|
client := &Client{
|
|
|
|
version: "1.29",
|
|
|
|
client: &http.Client{},
|
|
|
|
}
|
|
|
|
_, err := client.DistributionInspect(context.Background(), "foobar:1.0", "")
|
2018-03-13 19:28:34 +00:00
|
|
|
assert.Check(t, is.Error(err, `"distribution inspect" requires API version 1.30, but the Docker daemon API version is 1.29`))
|
2017-06-07 16:09:07 +00:00
|
|
|
}
|
2018-01-30 12:35:22 +00:00
|
|
|
|
|
|
|
func TestDistributionInspectWithEmptyID(t *testing.T) {
|
|
|
|
client := &Client{
|
|
|
|
client: newMockClient(func(req *http.Request) (*http.Response, error) {
|
|
|
|
return nil, errors.New("should not make request")
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
_, err := client.DistributionInspect(context.Background(), "", "")
|
|
|
|
if !IsErrNotFound(err) {
|
|
|
|
t.Fatalf("Expected NotFoundError, got %v", err)
|
|
|
|
}
|
|
|
|
}
|