2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2017-06-07 12:09:07 -04:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2017-06-07 12:09:07 -04:00
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2018-01-30 07:35:22 -05:00
|
|
|
"github.com/pkg/errors"
|
2018-06-11 09:32:11 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
is "gotest.tools/assert/cmp"
|
2017-06-07 12:09:07 -04: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 15:28:34 -04: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 12:09:07 -04:00
|
|
|
}
|
2018-01-30 07:35:22 -05: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)
|
|
|
|
}
|
|
|
|
}
|