distribution_inspect_test.go 885 B

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