refactor(netx): reorganize by topic (#800)
Before finishing the ongoing refactoring and leaving whatever is left of netx in tree, I would like to restructure it so that we'll have an easy time next time we need to modify it. Currently, every functionality lives into the `netx.go` file and we have a support file called `httptransport.go`. I would like to reorganize by topic, instead. This would allow future me to more easily perform topic-specific changes. While there, improve `netx`'s documentation and duplicate some of this documentation inside `internal/README.md` to provide pointers to previous documentation, historical context, and some help to understand the logic architecture of network extensions (aka `netx`). Part of https://github.com/ooni/probe-cli/pull/396
This commit is contained in:
parent
5d54aa9c5f
commit
64bffbd941
17 changed files with 703 additions and 528 deletions
33
internal/engine/netx/resolver_test.go
Normal file
33
internal/engine/netx/resolver_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package netx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
"github.com/ooni/probe-cli/v3/internal/tracex"
|
||||
)
|
||||
|
||||
func TestNewResolverBogonResolutionNotBroken(t *testing.T) {
|
||||
saver := new(tracex.Saver)
|
||||
r := NewResolver(Config{
|
||||
BogonIsError: true,
|
||||
DNSCache: map[string][]string{
|
||||
"www.google.com": {"127.0.0.1"},
|
||||
},
|
||||
Saver: saver,
|
||||
Logger: log.Log,
|
||||
})
|
||||
addrs, err := r.LookupHost(context.Background(), "www.google.com")
|
||||
if !errors.Is(err, netxlite.ErrDNSBogon) {
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
if err.Error() != netxlite.FailureDNSBogonError {
|
||||
t.Fatal("error not correctly wrapped")
|
||||
}
|
||||
if len(addrs) > 0 {
|
||||
t.Fatal("expected no addresses here")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue