refactor(netx): move construction logic outside package (#798)
For testability, replace most if-based construction logic with calls to well-tested factories living in other packages. While there, acknowledge that a bunch of types could now be private and make them private, modifying the code to call the public factories allowing to construct said types instead. Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
parent
2d3d5d9cdc
commit
6b85dfce88
20 changed files with 475 additions and 184 deletions
|
|
@ -100,21 +100,6 @@ func TestNewWithDialer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNewWithByteCounter(t *testing.T) {
|
||||
counter := bytecounter.New()
|
||||
txp := NewHTTPTransport(Config{
|
||||
ByteCounter: counter,
|
||||
})
|
||||
bctxp, ok := txp.(*bytecounter.HTTPTransport)
|
||||
if !ok {
|
||||
t.Fatal("not the transport we expected")
|
||||
}
|
||||
if bctxp.Counter != counter {
|
||||
t.Fatal("not the byte counter we expected")
|
||||
}
|
||||
// We are going to trust the underlying transport returned by netxlite
|
||||
}
|
||||
|
||||
func TestNewWithSaver(t *testing.T) {
|
||||
saver := new(tracex.Saver)
|
||||
txp := NewHTTPTransport(Config{
|
||||
|
|
|
|||
Loading…
Reference in a new issue