Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 426b18c

Browse files
authored
Fix dial tests (#439)
1 parent a778c5f commit 426b18c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

wsnet/dial.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er
178178

179179
err = dialer.negotiate(ctx)
180180
if err != nil {
181-
return nil, xerrors.Errorf("negotiate rtc connection: %w", err)
181+
// Return the dialer since we have tests that verify things are closed
182+
// if negotiation fails.
183+
return dialer, xerrors.Errorf("negotiate rtc connection: %w", err)
182184
}
183185

184186
return dialer, nil

wsnet/dial_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ func TestDial(t *testing.T) {
6262
defer cancelFunc()
6363
dialer, err := DialWebsocket(ctx, connectAddr, nil, nil)
6464
require.True(t, errors.Is(err, context.DeadlineExceeded))
65+
require.NotNil(t, dialer)
6566
require.Error(t, dialer.conn.Close(), "already wrote close")
67+
68+
// Ensure the rtc peer connection is closed. Setting the config options
69+
// to empty struct does nothing, but it does fail if the rtc peer conn
70+
// is closed.
71+
err = dialer.rtc.SetConfiguration(webrtc.Configuration{})
72+
require.Error(t, err)
73+
require.ErrorIs(t, err, webrtc.ErrConnectionClosed)
6674
})
6775

6876
t.Run("Ping", func(t *testing.T) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy