30 lines
720 B
Go
30 lines
720 B
Go
|
package mocks
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"crypto/tls"
|
||
|
"errors"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/lucas-clemente/quic-go"
|
||
|
)
|
||
|
|
||
|
func TestQUICContextDialerDialContext(t *testing.T) {
|
||
|
expected := errors.New("mocked error")
|
||
|
qcd := &QUICContextDialer{
|
||
|
MockDialContext: func(ctx context.Context, network string, address string, tlsConfig *tls.Config, quicConfig *quic.Config) (quic.EarlySession, error) {
|
||
|
return nil, expected
|
||
|
},
|
||
|
}
|
||
|
ctx := context.Background()
|
||
|
tlsConfig := &tls.Config{}
|
||
|
quicConfig := &quic.Config{}
|
||
|
sess, err := qcd.DialContext(ctx, "udp", "dns.google:443", tlsConfig, quicConfig)
|
||
|
if !errors.Is(err, expected) {
|
||
|
t.Fatal("not the error we expected")
|
||
|
}
|
||
|
if sess != nil {
|
||
|
t.Fatal("expected nil session")
|
||
|
}
|
||
|
}
|