possibly fix the test timeout in HostNameCollision

This commit is contained in:
mik2k2 2021-12-18 17:29:05 +01:00
parent 1d63444579
commit 664dbb0976

View File

@ -108,9 +108,11 @@ func TestHostNameCollision(t *testing.T) {
s, host := getHost(t, nil)
defer s.Close()
newUsers := make(chan *message.User)
newUsers1 := make(chan *message.User)
newUsers2 := make(chan *message.User)
host.OnUserJoined = func(u *message.User) {
newUsers <- u
newUsers1 <- u
newUsers2 <- u
}
go host.Serve()
@ -119,6 +121,7 @@ func TestHostNameCollision(t *testing.T) {
// First client
g.Go(func() error {
return sshd.ConnectShell(s.Addr().String(), "foo", func(r io.Reader, w io.WriteCloser) error {
<-newUsers1
scanner := bufio.NewScanner(r)
// Consume the initial buffer
@ -130,7 +133,7 @@ func TestHostNameCollision(t *testing.T) {
}
// wait for the second client
<-newUsers
<-newUsers1
scanner.Scan()
actual = scanner.Text()
@ -152,8 +155,9 @@ func TestHostNameCollision(t *testing.T) {
// Second client
g.Go(func() error {
// wait for the first client
<-newUsers
<-newUsers2
return sshd.ConnectShell(s.Addr().String(), "foo", func(r io.Reader, w io.WriteCloser) error {
<-newUsers2
scanner := bufio.NewScanner(r)
// Consume the initial buffer
scanner.Scan()