client_test.go 842 B

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