github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/agent/structs/testing_catalog.go (about)

     1  package structs
     2  
     3  import (
     4  	"github.com/mitchellh/go-testing-interface"
     5  )
     6  
     7  // TestRegisterRequest returns a RegisterRequest for registering a typical service.
     8  func TestRegisterRequest(t testing.T) *RegisterRequest {
     9  	return &RegisterRequest{
    10  		Datacenter: "dc1",
    11  		Node:       "foo",
    12  		Address:    "127.0.0.1",
    13  		Service: &NodeService{
    14  			Service: "web",
    15  			Address: "",
    16  			Port:    80,
    17  		},
    18  	}
    19  }
    20  
    21  // TestRegisterRequestProxy returns a RegisterRequest for registering a
    22  // Connect proxy.
    23  func TestRegisterRequestProxy(t testing.T) *RegisterRequest {
    24  	return &RegisterRequest{
    25  		Datacenter: "dc1",
    26  		Node:       "foo",
    27  		Address:    "127.0.0.1",
    28  		Service:    TestNodeServiceProxy(t),
    29  	}
    30  }
    31  
    32  // TestNodeService returns a *NodeService representing a valid regular service.
    33  func TestNodeService(t testing.T) *NodeService {
    34  	return &NodeService{
    35  		Kind:    ServiceKindTypical,
    36  		Service: "web",
    37  	}
    38  }
    39  
    40  // TestNodeServiceProxy returns a *NodeService representing a valid
    41  // Connect proxy.
    42  func TestNodeServiceProxy(t testing.T) *NodeService {
    43  	return &NodeService{
    44  		Kind:    ServiceKindConnectProxy,
    45  		Service: "web-proxy",
    46  		Address: "127.0.0.2",
    47  		Port:    2222,
    48  		Proxy:   TestConnectProxyConfig(t),
    49  	}
    50  }
    51  
    52  // TestNodeServiceSidecar returns a *NodeService representing a service
    53  // registration with a nested Sidecar registration.
    54  func TestNodeServiceSidecar(t testing.T) *NodeService {
    55  	return &NodeService{
    56  		Service: "web",
    57  		Port:    2222,
    58  		Connect: ServiceConnect{
    59  			SidecarService: &ServiceDefinition{},
    60  		},
    61  	}
    62  }