github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/cli/command/idresolver/client_test.go (about)

     1  package idresolver
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/docker/docker/api/types"
     7  	"github.com/docker/docker/api/types/swarm"
     8  	"github.com/docker/docker/client"
     9  )
    10  
    11  type fakeClient struct {
    12  	client.Client
    13  	nodeInspectFunc    func(string) (swarm.Node, []byte, error)
    14  	serviceInspectFunc func(string) (swarm.Service, []byte, error)
    15  }
    16  
    17  func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, nodeID string) (swarm.Node, []byte, error) {
    18  	if cli.nodeInspectFunc != nil {
    19  		return cli.nodeInspectFunc(nodeID)
    20  	}
    21  	return swarm.Node{}, []byte{}, nil
    22  }
    23  
    24  func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ types.ServiceInspectOptions) (swarm.Service, []byte, error) {
    25  	if cli.serviceInspectFunc != nil {
    26  		return cli.serviceInspectFunc(serviceID)
    27  	}
    28  	return swarm.Service{}, []byte{}, nil
    29  }