Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #419 from BetaXOi/fix-test
Browse files Browse the repository at this point in the history
client: do cleanup after UT stop mock server
  • Loading branch information
bergwolf authored Dec 7, 2018
2 parents 07a0832 + 4eca13b commit e7633c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion protocols/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const (
)

func startMockServer(t *testing.T, enableYamux bool) (*grpc.Server, chan error, error) {
os.Remove(mockSockAddr)
err := os.RemoveAll(mockSockAddr)
assert.Nil(t, err, "Remove %s failed", mockSockAddr)
if err != nil {
assert.FailNow(t, err.Error(), "Failed to start mock server")
}

l, err := net.Listen("unix", mockSockAddr)
assert.Nil(t, err, "Listen on %s failed: %s", mockSockAddr, err)
Expand Down Expand Up @@ -114,6 +118,7 @@ func agentClientTest(t *testing.T, sock string, success, enableYamux bool, expec
func TestNewAgentClient(t *testing.T) {
mock, waitCh, err := startMockServer(t, false)
assert.Nil(t, err, "failed to start mock server: %s", err)
defer os.Remove(mockSockAddr)

cliFunc := func(sock string, success bool, expect string) {
agentClientTest(t, sock, success, false, expect)
Expand All @@ -137,6 +142,7 @@ func TestNewAgentClient(t *testing.T) {
func TestNewAgentClientWithYamux(t *testing.T) {
mock, waitCh, err := startMockServer(t, true)
assert.Nil(t, err, "failed to start mock server: %s", err)
defer os.Remove(mockSockAddr)

cliFunc := func(sock string, success bool, expect string) {
agentClientTest(t, sock, success, true, expect)
Expand Down

0 comments on commit e7633c7

Please # to comment.