blob: ddb0c4fb53213502a6e4bb2677824bf97309db5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package client
import (
"context"
"errors"
"testing"
"codeberg.org/eduVPN/proxyguard"
)
func TestProxy(t *testing.T) {
// test race
p := Proxy{}
p.NewClient(&proxyguard.Client{})
go func() {
// connect to localhost will fail
// but we don't care about the error
_ = p.Tunnel(context.Background(), "127.0.0.1")
}()
// race!
_ = p.Cancel()
// cancel before tunneling
p.NewClient(&proxyguard.Client{})
if !errors.Is(p.Cancel(), ErrNoProxyGuardCancel) {
t.Fatalf("proxyguard cancel err not equal")
}
_ = p.Tunnel(context.Background(), "127.0.0.1")
p.Delete()
// tunnel without client
gerr := p.Tunnel(context.Background(), "127.0.0.1")
if !errors.Is(gerr, ErrNoProxyGuardClient) {
t.Fatalf("no proxyguard client err not equal")
}
}
|