distribution_inspect_test.go 898 B

12345678910111213141516171819202122232425262728293031
  1. package client // import "github.com/docker/docker/client"
  2. import (
  3. "context"
  4. "net/http"
  5. "testing"
  6. "github.com/docker/docker/errdefs"
  7. "github.com/pkg/errors"
  8. "gotest.tools/v3/assert"
  9. is "gotest.tools/v3/assert/cmp"
  10. )
  11. func TestDistributionInspectUnsupported(t *testing.T) {
  12. client := &Client{
  13. version: "1.29",
  14. client: &http.Client{},
  15. }
  16. _, err := client.DistributionInspect(context.Background(), "foobar:1.0", "")
  17. assert.Check(t, is.Error(err, `"distribution inspect" requires API version 1.30, but the Docker daemon API version is 1.29`))
  18. }
  19. func TestDistributionInspectWithEmptyID(t *testing.T) {
  20. client := &Client{
  21. client: newMockClient(func(req *http.Request) (*http.Response, error) {
  22. return nil, errors.New("should not make request")
  23. }),
  24. }
  25. _, err := client.DistributionInspect(context.Background(), "", "")
  26. assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
  27. }