test: change channel operations to avoid potential goroutine leaks

In these unit tests, goroutines may leak if certain branches are chosen. This commit edits channel operations and buffer sizes, so no matter what branch is chosen, the test will end correctly. This commit doesn't change the semantics of unit tests.
This commit is contained in:
lzhfromustc
2020-12-09 22:23:21 -05:00
parent ca866c0242
commit f2a912a4e6
6 changed files with 20 additions and 18 deletions

View File

@ -213,7 +213,7 @@ func TestApplyRepeat(t *testing.T) {
// wait for conf change message
act, err := n.Wait(1)
// wait for stop message (async to avoid deadlock)
stopc := make(chan error)
stopc := make(chan error, 1)
go func() {
_, werr := n.Wait(1)
stopc <- werr