netxlite: code quality, improve tests, docs (#494)

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-08 22:48:10 +02:00 committed by GitHub
commit 50b58672c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 318 additions and 154 deletions

View file

@ -12,6 +12,26 @@ import (
utls "gitlab.com/yawning/utls.git"
)
func TestResolver(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
t.Run("works as intended", func(t *testing.T) {
// TODO(bassosimone): this is actually an integration
// test but how to test this case?
r := netxlite.NewResolverSystem(log.Log)
defer r.CloseIdleConnections()
addrs, err := r.LookupHost(context.Background(), "dns.google.com")
if err != nil {
t.Fatal(err)
}
if addrs == nil {
t.Fatal("expected non-nil result here")
}
})
}
func TestHTTPTransport(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")