github.com/rish1988/moby@v25.0.2+incompatible/client/distribution_inspect_test.go (about)

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