urlgetter: fix tunnel test (#299)
* urlgetter: fix tunnel test This diff fixes the urlgetter test suite to make sure we are correctly testing for tunnel creation. While there, improve the way in which we create a testing directory and add a test for that. Part of https://github.com/ooni/probe/issues/985. * fix comment * fix comment
This commit is contained in:
parent
973501dd11
commit
6aa2551c43
5 changed files with 845 additions and 749 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/armon/go-socks5"
|
||||
|
|
@ -41,6 +42,25 @@ func TestFakeWithEmptyTunnelDir(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFakeWithFailingMkdirAll(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
ctx := context.Background()
|
||||
sess := &mockable.Session{}
|
||||
tunnel, err := fakeStart(ctx, &Config{
|
||||
Session: sess,
|
||||
TunnelDir: "testdata",
|
||||
testMkdirAll: func(dir string, mode os.FileMode) error {
|
||||
return expected
|
||||
},
|
||||
})
|
||||
if !errors.Is(err, expected) {
|
||||
t.Fatal("not the error we expected")
|
||||
}
|
||||
if tunnel != nil {
|
||||
t.Fatal("expected nil tunnel here")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeSocks5NewFails(t *testing.T) {
|
||||
expected := errors.New("mocked error")
|
||||
ctx := context.Background()
|
||||
|
|
|
|||
Loading…
Reference in a new issue