netxlite: improve docs, tests, and code quality (#493)
* netxlite: improve docs, tests, and code quality * better documentation * more strict testing of dialer (especially make sure we document the quirk in https://github.com/ooni/probe/issues/1779 and we have tests to guarantee we don't screw up here) * introduce NewErrWrapper factory for creating errors so we have confidence we are creating them correctly Part of https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
e68adec9a5
commit
3cd88debdc
12 changed files with 452 additions and 141 deletions
|
|
@ -35,12 +35,16 @@ func TestQuirkReduceErrors(t *testing.T) {
|
|||
|
||||
t.Run("multiple errors with meaningful ones", func(t *testing.T) {
|
||||
err1 := errors.New("mocked error #1")
|
||||
err2 := &errorsx.ErrWrapper{
|
||||
Failure: "unknown_failure: antani",
|
||||
}
|
||||
err3 := &errorsx.ErrWrapper{
|
||||
Failure: errorsx.FailureConnectionRefused,
|
||||
}
|
||||
err2 := errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError,
|
||||
errorsx.CloseOperation,
|
||||
errors.New("antani"),
|
||||
)
|
||||
err3 := errorsx.NewErrWrapper(
|
||||
errorsx.ClassifyGenericError,
|
||||
errorsx.CloseOperation,
|
||||
errorsx.ECONNREFUSED,
|
||||
)
|
||||
err4 := errors.New("mocked error #3")
|
||||
result := quirkReduceErrors([]error{err1, err2, err3, err4})
|
||||
if result.Error() != errorsx.FailureConnectionRefused {
|
||||
|
|
|
|||
Loading…
Reference in a new issue