github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+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/pkg/errors"
     9  	"gotest.tools/v3/assert"
    10  	is "gotest.tools/v3/assert/cmp"
    11  )
    12  
    13  func TestDistributionInspectUnsupported(t *testing.T) {
    14  	client := &Client{
    15  		version: "1.29",
    16  		client:  &http.Client{},
    17  	}
    18  	_, err := client.DistributionInspect(context.Background(), "foobar:1.0", "")
    19  	assert.Check(t, is.Error(err, `"distribution inspect" requires API version 1.30, but the Docker daemon API version is 1.29`))
    20  }
    21  
    22  func TestDistributionInspectWithEmptyID(t *testing.T) {
    23  	client := &Client{
    24  		client: newMockClient(func(req *http.Request) (*http.Response, error) {
    25  			return nil, errors.New("should not make request")
    26  		}),
    27  	}
    28  	_, err := client.DistributionInspect(context.Background(), "", "")
    29  	if !IsErrNotFound(err) {
    30  		t.Fatalf("Expected NotFoundError, got %v", err)
    31  	}
    32  }