-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_test.go
44 lines (41 loc) · 1.03 KB
/
check_test.go
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
37
38
39
40
41
42
43
44
package socks4dialer
import (
"reflect"
"testing"
)
func Test_doCheckRequest(t *testing.T) {
type args struct {
proxyAddr string
dstURL string
}
tests := []struct {
name string
args args
wantBody []byte
wantErr bool
}{
// TODO: replaces proxy addresses with yours.
{name: "test socks4 http request #0",
args: args{proxyAddr: "socks4://ip:port", dstURL: "http://icanhazip.com"},
wantBody: []byte("ip:port"),
wantErr: false,
},
{name: "test socks4 https request #0",
args: args{proxyAddr: "socks4://ip:port", dstURL: "https://icanhazip.com"},
wantBody: []byte("ip:port"),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotBody, err := doCheckRequest(tt.args.proxyAddr, tt.args.dstURL)
if (err != nil) != tt.wantErr {
t.Errorf("doCheckRequest() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotBody, tt.wantBody) {
t.Errorf("doCheckRequest() = %s, want %s", gotBody, tt.wantBody)
}
})
}
}