fix(netxlite/quic): wrap Close (#509)
While there, make sure netxlite has 100% coverage. Part of https://github.com/ooni/probe/issues/1733 and diff has been extracted from https://github.com/ooni/probe-cli/pull/506.
This commit is contained in:
parent
deb1589bdb
commit
273774bb03
3 changed files with 48 additions and 1 deletions
|
|
@ -472,6 +472,7 @@ func TestQUICLoggerDialer(t *testing.T) {
|
|||
func TestNewSingleUseQUICDialer(t *testing.T) {
|
||||
sess := &mocks.QUICEarlySession{}
|
||||
qd := NewSingleUseQUICDialer(sess)
|
||||
defer qd.CloseIdleConnections()
|
||||
outsess, err := qd.DialContext(
|
||||
context.Background(), "", "", &tls.Config{}, &quic.Config{})
|
||||
if err != nil {
|
||||
|
|
@ -618,6 +619,37 @@ func TestQUICErrWrapperUDPLikeConn(t *testing.T) {
|
|||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Close", func(t *testing.T) {
|
||||
t.Run("on success", func(t *testing.T) {
|
||||
conn := &quicErrWrapperUDPLikeConn{
|
||||
UDPLikeConn: &mocks.QUICUDPLikeConn{
|
||||
MockClose: func() error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
}
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("on failure", func(t *testing.T) {
|
||||
expectedErr := io.EOF
|
||||
conn := &quicErrWrapperUDPLikeConn{
|
||||
UDPLikeConn: &mocks.QUICUDPLikeConn{
|
||||
MockClose: func() error {
|
||||
return expectedErr
|
||||
},
|
||||
},
|
||||
}
|
||||
err := conn.Close()
|
||||
if err == nil || err.Error() != errorsx.FailureEOFError {
|
||||
t.Fatal("unexpected err", err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestQUICDialerErrWrapper(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue