refactor(oohelperd): flatten package hierarchy (#834)
In https://github.com/ooni/probe-cli/pull/832's initial diff, I mentioned it would be cool to flatten oohelperd's hier. I'm doing this now, and just for the master branch. This diff is mostly a mechanical refactoring with very light and apparently rather safe manual changes.
This commit is contained in:
parent
a4d17085f5
commit
535a5d3e00
12 changed files with 151 additions and 98 deletions
40
internal/cmd/oohelperd/tcpconnect_test.go
Normal file
40
internal/cmd/oohelperd/tcpconnect_test.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
func Test_tcpMapFailure(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
failure *string
|
||||
want *string
|
||||
}{{
|
||||
name: "nil",
|
||||
failure: nil,
|
||||
want: nil,
|
||||
}, {
|
||||
name: "timeout",
|
||||
failure: stringPointerForString(netxlite.FailureGenericTimeoutError),
|
||||
want: stringPointerForString(netxlite.FailureGenericTimeoutError),
|
||||
}, {
|
||||
name: "connection refused",
|
||||
failure: stringPointerForString(netxlite.FailureConnectionRefused),
|
||||
want: stringPointerForString("connection_refused_error"),
|
||||
}, {
|
||||
name: "anything else",
|
||||
failure: stringPointerForString(netxlite.FailureEOFError),
|
||||
want: stringPointerForString("connect_error"),
|
||||
}}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := tcpMapFailure(tt.failure)
|
||||
if diff := cmp.Diff(tt.want, got); diff != "" {
|
||||
t.Fatal(diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue