Skip to content

Commit

Permalink
Add StartOnAddress function to listen on unix:// paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jsafrane committed Feb 11, 2019
1 parent d400bcc commit ddb689f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions driver/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func NewMockCSIDriver(servers *MockCSIDriverServers) *MockCSIDriver {
}
}

func (m *MockCSIDriver) Start() error {
// Listen on a port assigned by the net package
l, err := net.Listen("tcp", "127.0.0.1:0")
// StartOnAddress starts a new gRPC server listening on given address.
func (m *MockCSIDriver) StartOnAddress(network, address string) error {
l, err := net.Listen(network, address)
if err != nil {
return err
}
Expand All @@ -61,6 +61,12 @@ func (m *MockCSIDriver) Start() error {
return nil
}

// Start starts a new gRPC server listening on a random TCP loopback port.
func (m *MockCSIDriver) Start() error {
// Listen on a port assigned by the net package
return m.StartOnAddress("tcp", "127.0.0.1:0")
}

func (m *MockCSIDriver) Nexus() (*grpc.ClientConn, error) {
// Start server
err := m.Start()
Expand Down

0 comments on commit ddb689f

Please sign in to comment.